From 60a0600cde297e8fd081028fbf4443036e6186fd Mon Sep 17 00:00:00 2001 From: tcely Date: Sat, 21 Dec 2024 01:07:57 -0500 Subject: [PATCH] Use Path in file_is_editable --- tubesync/sync/utils.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tubesync/sync/utils.py b/tubesync/sync/utils.py index 1c00b4a2..19ddeb0a 100644 --- a/tubesync/sync/utils.py +++ b/tubesync/sync/utils.py @@ -99,15 +99,16 @@ def file_is_editable(filepath): ''' allowed_paths = ( # Media item thumbnails - os.path.commonpath([os.path.abspath(str(settings.MEDIA_ROOT))]), + Path(str(settings.MEDIA_ROOT)).resolve(), + # Downloaded media files - os.path.commonpath([os.path.abspath(str(settings.DOWNLOAD_ROOT))]), + Path(str(settings.DOWNLOAD_ROOT)).resolve(), ) - filepath = os.path.abspath(str(filepath)) - if not os.path.isfile(filepath): + filepath = Path(str(filepath)).resolve() + if not filepath.is_file(): return False for allowed_path in allowed_paths: - if allowed_path == os.path.commonpath([allowed_path, filepath]): + if str(allowed_path) == os.path.commonpath([allowed_path, filepath]): return True return False