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:
+10
-1
@@ -46,7 +46,7 @@ def _convert_bg(relative_path):
|
|||||||
try:
|
try:
|
||||||
source_path = _local_path(relative_path)
|
source_path = _local_path(relative_path)
|
||||||
mp4_relative = os.path.splitext(relative_path)[0] + ".mp4"
|
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):
|
if not app_dash.begin_local_video_use(relative_path):
|
||||||
return
|
return
|
||||||
@@ -96,6 +96,15 @@ def _local_path(relative_path):
|
|||||||
return app_dash.safe_video_path(app_dash.DEFAULT_DESTINATION, 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):
|
def _thumbnail_path(relative_path):
|
||||||
source_root = os.path.realpath(app_dash.DEFAULT_DESTINATION)
|
source_root = os.path.realpath(app_dash.DEFAULT_DESTINATION)
|
||||||
source_path = app_dash.safe_video_path(source_root, relative_path)
|
source_path = app_dash.safe_video_path(source_root, relative_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user