Use Path in file_is_editable

This commit is contained in:
tcely 2024-12-21 01:07:57 -05:00 committed by GitHub
parent 52865cb5b4
commit 60a0600cde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -99,15 +99,16 @@ def file_is_editable(filepath):
''' '''
allowed_paths = ( allowed_paths = (
# Media item thumbnails # Media item thumbnails
os.path.commonpath([os.path.abspath(str(settings.MEDIA_ROOT))]), Path(str(settings.MEDIA_ROOT)).resolve(),
# Downloaded media files # 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)) filepath = Path(str(filepath)).resolve()
if not os.path.isfile(filepath): if not filepath.is_file():
return False return False
for allowed_path in allowed_paths: 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 True
return False return False