Skip to content

Commit

Permalink
Worker 添加file_size 属性
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-cq committed Mar 3, 2024
1 parent d767018 commit f81b07a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions alist_sync/d_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ def __del__(self):
finally:
pass

@computed_field()
@property
def file_size(self) -> int | None:
if self.source_path is None:
return None
return self.source_path.stat().size

@computed_field(return_type=str, alias="_id")
@property
def id(self) -> str:
Expand Down
5 changes: 4 additions & 1 deletion alist_sync/data_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""
import abc
import datetime
import json
import logging
import shelve
from pathlib import Path
Expand Down Expand Up @@ -89,7 +90,9 @@ def update_worker(self, worker: "Worker", *field):
else:
data = {k: worker.__dict__.get(k) for k in field}

logger.debug(f"Worker[{worker.id}]: Update: {data}")
logger.debug(
f"Worker[{worker.id}]: Update: {json.dumps(data, indent=2, ensure_ascii=False)}"
)
return self._workers.update_one(
{"_id": worker.id},
{"$set": data},
Expand Down

0 comments on commit f81b07a

Please sign in to comment.