fix(subtitle): 2차 파일명 체크 — Content-Disposition 파일명으로 존재 확인 후 쓰기

This commit is contained in:
2026-03-19 07:06:27 +09:00
parent f96c28a72d
commit bb59e7caca

View File

@@ -252,7 +252,7 @@ class SubtitleDownloader:
target_dir = Path(save_dir) if save_dir else self.download_dir
target_dir.mkdir(parents=True, exist_ok=True)
# 이미 같은 파일명이 존재하면 스킵
# 이미 같은 파일명이 존재하면 스킵 (1차 — 원본 파일명 기준)
existing = target_dir / sub.filename
if existing.exists() and existing.stat().st_size > 0:
logger.info(f"자막 이미 존재, 스킵: {existing}")
@@ -280,7 +280,13 @@ class SubtitleDownloader:
if m:
sub.filename = unquote(m.group(1).strip())
# 실제 파일명으로 2차 존재 체크 (Content-Disposition 반영 후)
filepath = target_dir / sub.filename
if filepath.exists() and filepath.stat().st_size > 0:
logger.info(f"자막 이미 존재 (실제 파일명), 스킵: {filepath}")
sub.local_path = str(filepath)
return str(filepath)
filepath.write_bytes(resp.content)
# ZIP/7z 자동 해제