feat(preflight): 报告改为集中目录 + 时间戳
- [Compatibility] report_dir(默认 /hdd/sda1/Quark-Down/_reports) - 文件名 preflight-YYYYmmdd-HHMMSS.xlsx,同秒冲突自动加序号 - 媒体库根目录不再产生 preflight_report.*
This commit is contained in:
@@ -322,6 +322,19 @@ class PreflightService:
|
||||
]))
|
||||
return rows
|
||||
|
||||
@staticmethod
|
||||
def _report_path(ext: str) -> Path:
|
||||
"""集中目录 + 时间戳:<report_dir>/preflight-YYYYmmdd-HHMMSS.<ext>"""
|
||||
report_dir = config.PREFLIGHT_REPORT_DIR
|
||||
report_dir.mkdir(parents=True, exist_ok=True)
|
||||
stamp = time.strftime("%Y%m%d-%H%M%S")
|
||||
path = report_dir / f"preflight-{stamp}.{ext}"
|
||||
n = 2
|
||||
while path.exists():
|
||||
path = report_dir / f"preflight-{stamp}-{n}.{ext}"
|
||||
n += 1
|
||||
return path
|
||||
|
||||
@classmethod
|
||||
def write_report(cls, root: Path, results: list, only_issues: bool = False) -> Path | None:
|
||||
"""results: [(path, PreflightResult)],输出 root/preflight_report.xlsx(无 openpyxl 时退回 csv)。"""
|
||||
@@ -387,14 +400,14 @@ class PreflightService:
|
||||
for col, width in widths.items():
|
||||
ws.column_dimensions[col].width = width
|
||||
|
||||
report = root / "preflight_report.xlsx"
|
||||
report = cls._report_path("xlsx")
|
||||
wb.save(report)
|
||||
log.info(f"📄 兼容性报告: {report}")
|
||||
return report
|
||||
|
||||
@classmethod
|
||||
def _write_csv(cls, root: Path, rows: list) -> Path:
|
||||
report = root / "preflight_report.csv"
|
||||
report = cls._report_path("csv")
|
||||
lines = [",".join(cls.HEADERS) + "\n"]
|
||||
for _, _, values in rows:
|
||||
lines.append(",".join('"' + str(v).replace('"', '""') + '"' for v in values) + "\n")
|
||||
|
||||
Reference in New Issue
Block a user