fix filepath regression

This commit is contained in:
Alex Shnitman
2026-02-14 08:58:01 +02:00
parent 8ae06c65d0
commit 3bf7fb51f4

View File

@@ -144,7 +144,21 @@ class Download:
def put_status_postprocessor(d): def put_status_postprocessor(d):
if d['postprocessor'] == 'MoveFiles' and d['status'] == 'finished': if d['postprocessor'] == 'MoveFiles' and d['status'] == 'finished':
filename = d['info_dict']['filepath'] filepath = d['info_dict']['filepath']
if '__finaldir' in d['info_dict']:
finaldir = d['info_dict']['__finaldir']
# Compute relative path from temp dir to preserve
# subdirectory structure from the output template.
try:
rel_path = os.path.relpath(filepath, self.temp_dir)
except ValueError:
rel_path = os.path.basename(filepath)
if rel_path.startswith('..'):
# filepath is not under temp_dir, fall back to basename
rel_path = os.path.basename(filepath)
filename = os.path.join(finaldir, rel_path)
else:
filename = filepath
self.status_queue.put({'status': 'finished', 'filename': filename}) self.status_queue.put({'status': 'finished', 'filename': filename})
# Capture all chapter files when SplitChapters finishes # Capture all chapter files when SplitChapters finishes