forked from kenzuya/unshackle
fix(dl): always clean up hybrid temp hevc outputs
This commit is contained in:
@@ -1837,6 +1837,9 @@ class dl:
|
||||
append_audio_codec_suffix = merge_audio
|
||||
|
||||
multiplex_tasks: list[tuple[TaskID, Tracks, Optional[Audio.Codec]]] = []
|
||||
# Track hybrid-processing outputs explicitly so we can always clean them up,
|
||||
# even if muxing fails early (e.g. SystemExit) before the normal delete loop.
|
||||
hybrid_temp_paths: list[Path] = []
|
||||
|
||||
def clone_tracks_for_audio(base_tracks: Tracks, audio_tracks: list[Audio]) -> Tracks:
|
||||
task_tracks = Tracks()
|
||||
@@ -1898,10 +1901,13 @@ class dl:
|
||||
# Create unique output filename for this resolution
|
||||
hybrid_filename = f"HDR10-DV-{resolution}p.hevc"
|
||||
hybrid_output_path = config.directories.temp / hybrid_filename
|
||||
hybrid_temp_paths.append(hybrid_output_path)
|
||||
|
||||
# The Hybrid class creates HDR10-DV.hevc, rename it for this resolution
|
||||
default_output = config.directories.temp / "HDR10-DV.hevc"
|
||||
if default_output.exists():
|
||||
# If a previous run left this behind, replace it to avoid move() failures.
|
||||
hybrid_output_path.unlink(missing_ok=True)
|
||||
shutil.move(str(default_output), str(hybrid_output_path))
|
||||
|
||||
# Create tracks with the hybrid video output for this resolution
|
||||
@@ -1936,6 +1942,7 @@ class dl:
|
||||
|
||||
enqueue_mux_tasks(task_description, task_tracks)
|
||||
|
||||
try:
|
||||
with Live(Padding(progress, (0, 5, 1, 5)), console=console):
|
||||
mux_index = 0
|
||||
for task_id, task_tracks, audio_codec in multiplex_tasks:
|
||||
@@ -2010,6 +2017,20 @@ class dl:
|
||||
temp_path.unlink(missing_ok=True)
|
||||
for temp_path in sidecar_original_paths.values():
|
||||
temp_path.unlink(missing_ok=True)
|
||||
finally:
|
||||
# Hybrid() produces a temp HEVC output we rename; make sure it's never left behind.
|
||||
# Also attempt to remove the default hybrid output name if it still exists.
|
||||
for temp_path in hybrid_temp_paths:
|
||||
try:
|
||||
temp_path.unlink(missing_ok=True)
|
||||
except PermissionError:
|
||||
self.log.warning(f"Failed to delete temp file (in use?): {temp_path}")
|
||||
try:
|
||||
(config.directories.temp / "HDR10-DV.hevc").unlink(missing_ok=True)
|
||||
except PermissionError:
|
||||
self.log.warning(
|
||||
f"Failed to delete temp file (in use?): {config.directories.temp / 'HDR10-DV.hevc'}"
|
||||
)
|
||||
|
||||
else:
|
||||
# dont mux
|
||||
|
||||
Reference in New Issue
Block a user