From 5f04628178cd69078af964eeb5efa2ab02bb2c03 Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 12 Nov 2019 09:39:21 -0400 Subject: [PATCH] No need to str(path) anymore for model item Upload --- src/python/matrix_client.py | 2 +- src/python/models/items.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/python/matrix_client.py b/src/python/matrix_client.py index 96561453..4908b777 100644 --- a/src/python/matrix_client.py +++ b/src/python/matrix_client.py @@ -191,7 +191,7 @@ class MatrixClient(nio.AsyncClient): size = path.resolve().stat().st_size encrypt = room_id in self.encrypted_rooms - upload_item = Upload(str(path), total_size=size) + upload_item = Upload(path, total_size=size) self.models[Upload, room_id][upload_item.uuid] = upload_item url, mime, crypt_dict = await self.upload_file( diff --git a/src/python/models/items.py b/src/python/models/items.py index 102f7882..091387a3 100644 --- a/src/python/models/items.py +++ b/src/python/models/items.py @@ -115,7 +115,7 @@ class UploadStatus(AutoStrEnum): @dataclass class Upload(ModelItem): - filepath: str = field() + filepath: Path = field() status: UploadStatus = UploadStatus.Starting total_size: int = 0 uploaded: int = 0 @@ -126,7 +126,7 @@ class Upload(ModelItem): def __post_init__(self) -> None: if not self.total_size: - self.total_size = Path(self.filepath).resolve().stat().st_size + self.total_size = self.filepath.resolve().stat().st_size def __lt__(self, other: "Upload") -> bool: