fix(variety): 已跟随的附属文件不再二次认领

- adopt_orphan_sidecars 对 <视频名>-thumb.jpg 这类已经改好的文件仍会再拼一次尾巴,
  导致文件名指数级变长,最终 OSError: File name too long
- 现在先判断「是否已经以视频名开头」,是则跳过;rename 也包了 try/except
- 清理了 1 个 304 字节的超长残留;重跑三个目录均 0 改动(幂等)
This commit is contained in:
ali
2026-11-20 01:00:47 +08:00
parent d1a3327839
commit 87a6bc2753
+8 -1
View File
@@ -359,11 +359,18 @@ class VarietyService:
video = by_date.get(match.group(1)) video = by_date.get(match.group(1))
if not video or video.parent != side.parent: if not video or video.parent != side.parent:
continue 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) rest = re.sub(r"^.*?\d{8}", "", side.stem)
target = video.with_name(f"{video.stem}{rest}{side.suffix.lower()}") target = video.with_name(f"{video.stem}{rest}{side.suffix.lower()}")
if target == side or target.exists(): if target == side:
continue continue
try: try:
if target.exists():
continue
side.rename(target) side.rename(target)
adopted += 1 adopted += 1
except OSError as exc: except OSError as exc: