From 87a6bc275394ed332fe21776339522614c38a970 Mon Sep 17 00:00:00 2001 From: ali Date: Fri, 20 Nov 2026 01:00:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(variety):=20=E5=B7=B2=E8=B7=9F=E9=9A=8F?= =?UTF-8?q?=E7=9A=84=E9=99=84=E5=B1=9E=E6=96=87=E4=BB=B6=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E4=BA=8C=E6=AC=A1=E8=AE=A4=E9=A2=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - adopt_orphan_sidecars 对 <视频名>-thumb.jpg 这类已经改好的文件仍会再拼一次尾巴, 导致文件名指数级变长,最终 OSError: File name too long - 现在先判断「是否已经以视频名开头」,是则跳过;rename 也包了 try/except - 清理了 1 个 304 字节的超长残留;重跑三个目录均 0 改动(幂等) --- media/src/services/variety.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/media/src/services/variety.py b/media/src/services/variety.py index 233a894..8a2a37e 100644 --- a/media/src/services/variety.py +++ b/media/src/services/variety.py @@ -359,11 +359,18 @@ class VarietyService: video = by_date.get(match.group(1)) if not video or video.parent != side.parent: continue + # 已经跟着视频名了(<视频名>-thumb.jpg 这种),不要再认领一次, + # 否则会把尾巴反复拼接到超长路径 + if side.name == video.stem or side.name.startswith(f"{video.stem}.") \ + or side.name.startswith(f"{video.stem}-"): + continue rest = re.sub(r"^.*?\d{8}", "", side.stem) target = video.with_name(f"{video.stem}{rest}{side.suffix.lower()}") - if target == side or target.exists(): + if target == side: continue try: + if target.exists(): + continue side.rename(target) adopted += 1 except OSError as exc: