fix: 显示任务传输状态

This commit is contained in:
2026-06-20 12:50:43 +08:00
parent 0e3dc9a96f
commit c2289f889e
9 changed files with 130 additions and 33 deletions
+21 -4
View File
@@ -605,7 +605,7 @@ def start_schedule(row: sqlite3.Row, trigger: str) -> None:
"srcFs": row["src"],
"dstFs": row["dst"],
"_async": True,
"_group": f"webgui/recurring/{schedule_id}/{action}",
"_group": transfer_group("recurring", schedule_id, action),
}
if action == "move":
payload["deleteEmptySrcDirs"] = True
@@ -686,7 +686,7 @@ def start_one_time_job(job_id: int) -> None:
"srcFs": row["src"],
"dstFs": row["dst"],
"_async": True,
"_group": f"webgui/once/{job_id}/{action}",
"_group": transfer_group("once", job_id, action),
}
if action == "move":
payload["deleteEmptySrcDirs"] = True
@@ -744,6 +744,23 @@ def status_name(status: dict[str, Any]) -> str:
return "finished"
def transfer_group(kind: str, record_id: int, action: str) -> str:
return f"webgui/{kind}/{record_id}/{action}"
def status_with_stats(kind: str, row: sqlite3.Row, jobid: int) -> dict[str, Any]:
status = rc_post("job/status", {"jobid": jobid}, timeout=15, allow_error_body=True)
group = transfer_group(kind, int(row["id"]), row["action"])
try:
stats = rc_post("core/stats", {"group": group}, timeout=15, allow_error_body=True)
except Exception as exc:
stats = {"error": str(exc)}
status["stats"] = stats
if "group" not in status:
status["group"] = group
return status
def refresh_running_jobs() -> None:
with db_lock, connect() as conn:
rows = conn.execute("SELECT * FROM job_schedules WHERE current_jobid IS NOT NULL").fetchall()
@@ -752,7 +769,7 @@ def refresh_running_jobs() -> None:
schedule_id = int(row["id"])
jobid = int(row["current_jobid"])
try:
status = rc_post("job/status", {"jobid": jobid}, timeout=15, allow_error_body=True)
status = status_with_stats("recurring", row, jobid)
except Exception as exc:
status = {"finished": True, "error": str(exc), "jobid": jobid}
apply_status(row, status)
@@ -765,7 +782,7 @@ def refresh_one_time_jobs() -> None:
for row in rows:
jobid = int(row["jobid"])
try:
status = rc_post("job/status", {"jobid": jobid}, timeout=15, allow_error_body=True)
status = status_with_stats("once", row, jobid)
except Exception as exc:
status = {"finished": True, "error": str(exc), "jobid": jobid}
apply_one_time_status(row, status)