Skip to content

Commit 904c57f

Browse files
authored
Merge pull request #592 from tcely/patch-6
Use Path in file_is_editable
2 parents cfb8bef + 60a0600 commit 904c57f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tubesync/sync/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,16 @@ def file_is_editable(filepath):
100100
'''
101101
allowed_paths = (
102102
# Media item thumbnails
103-
os.path.commonpath([os.path.abspath(str(settings.MEDIA_ROOT))]),
103+
Path(str(settings.MEDIA_ROOT)).resolve(),
104+
104105
# Downloaded media files
105-
os.path.commonpath([os.path.abspath(str(settings.DOWNLOAD_ROOT))]),
106+
Path(str(settings.DOWNLOAD_ROOT)).resolve(),
106107
)
107-
filepath = os.path.abspath(str(filepath))
108-
if not os.path.isfile(filepath):
108+
filepath = Path(str(filepath)).resolve()
109+
if not filepath.is_file():
109110
return False
110111
for allowed_path in allowed_paths:
111-
if allowed_path == os.path.commonpath([allowed_path, filepath]):
112+
if str(allowed_path) == os.path.commonpath([allowed_path, filepath]):
112113
return True
113114
return False
114115

0 commit comments

Comments
 (0)