diff options
author | Maxim Devaev <[email protected]> | 2022-11-10 05:05:30 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2022-11-10 05:05:30 +0300 |
commit | d4e1e9e05bb4fabc6fd3f86dc21b2c3378002f03 (patch) | |
tree | 3d0f24e479eb10cfe2e24f22d3e95c68831a3670 /kvmd | |
parent | 666880d757f91c05aa8cb8810bd0da44045b10df (diff) |
Fixed pikvm/pikvm#842: Added timestamps for MSD images
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/plugins/msd/otg/__init__.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py index 4ef47097..87e88ea7 100644 --- a/kvmd/plugins/msd/otg/__init__.py +++ b/kvmd/plugins/msd/otg/__init__.py @@ -69,12 +69,16 @@ class _DriveImage: complete: bool in_storage: bool size: int = dataclasses.field(default=0) + mod_ts: float = dataclasses.field(default=0) def __post_init__(self) -> None: try: - object.__setattr__(self, "size", max(os.path.getsize(self.path), 0)) + st = os.stat(self.path) except Exception as err: - get_logger().warning("Can't get size of file %s: %s", self.path, err) + get_logger().warning("Can't stat() file %s: %s", self.path, err) + else: + object.__setattr__(self, "size", st.st_size) + object.__setattr__(self, "mod_ts", st.st_mtime) @dataclasses.dataclass(frozen=True) |