fix(videos): fix FileNotFoundError crashing convert thread

safe_video_path checks file existence — mp4 output doesn't exist yet.
Add _local_path_unchecked() for output paths that don't exist yet.

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Mathieu Moran
2026-08-10 01:35:31 -04:00
co-authored by Copilot
parent d9d1537a13
commit e8ce33eded
+10 -1
View File
@@ -46,7 +46,7 @@ def _convert_bg(relative_path):
try:
source_path = _local_path(relative_path)
mp4_relative = os.path.splitext(relative_path)[0] + ".mp4"
mp4_path = _local_path(mp4_relative)
mp4_path = _local_path_unchecked(mp4_relative)
if not app_dash.begin_local_video_use(relative_path):
return
@@ -96,6 +96,15 @@ def _local_path(relative_path):
return app_dash.safe_video_path(app_dash.DEFAULT_DESTINATION, relative_path)
def _local_path_unchecked(relative_path):
"""Build absolute path without requiring the file to already exist."""
base = os.path.realpath(app_dash.DEFAULT_DESTINATION)
target = os.path.realpath(os.path.join(base, relative_path))
if os.path.commonpath([base, target]) != base:
raise ValueError("Path escapes video directory.")
return target
def _thumbnail_path(relative_path):
source_root = os.path.realpath(app_dash.DEFAULT_DESTINATION)
source_path = app_dash.safe_video_path(source_root, relative_path)