feat: 未知进度不显示进度条并增加任务详情

This commit is contained in:
2026-10-25 05:46:55 +08:00
parent 4cf64957c5
commit 85e6653da4
5 changed files with 194 additions and 10 deletions
+11
View File
@@ -81,6 +81,7 @@ class DownloadJob:
"completed": self.completed,
"failed": self.failed,
"writtenRows": self.written_rows,
"fileBytes": _file_bytes(self.csv_path),
"csvPath": str(self.csv_path),
"failures": self.failures[-20:],
"createdAt": self.created_at,
@@ -122,6 +123,15 @@ class DownloadJob:
await subscriber.put(event)
def _file_bytes(path: str | Path) -> int:
if not path:
return 0
try:
return Path(path).stat().st_size
except OSError:
return 0
def _set_event() -> asyncio.Event:
event = asyncio.Event()
event.set()
@@ -353,6 +363,7 @@ class JobManager:
"completed": finished or data.get("completed") or 0,
"failed": data.get("failed") or 0,
"writtenRows": written or data.get("writtenRows") or 0,
"fileBytes": _file_bytes(data.get("csvPath") or ""),
"csvPath": data.get("csvPath"),
"failures": data.get("failures") or [],
"createdAt": data.get("createdAt"),