mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
Fixed pikvm/pikvm#842: Added timestamps for MSD images
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user