# -*- coding: utf-8 -*- """备份上传进度(写入 data/baidu_backup/上传进度.txt)。""" from __future__ import annotations from datetime import datetime import _bootstrap # noqa: F401 import backup_settings as S def write_progress(*, status: str, detail: str = "", uploaded: int = 0, total: int = 0) -> None: S.STATE_DIR.mkdir(parents=True, exist_ok=True) pct = (uploaded / total * 100.0) if total else 0.0 lines = [ f"1、状态:{status}", f"2、上传项:{uploaded}/{total}", f"3、进度:{pct:.1f}%", f"4、详情:{detail or '-'}", "", f"更新时间:{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}", ] S.PROGRESS_FILE.write_text("\n".join(lines) + "\n", encoding="utf-8")