Skip to content

Commit 8c0f716

Browse files
authored
Merge pull request #2002 from flesueur/master
Improve performance of `path_to_filesystem()`
2 parents 7e3d4b3 + 0be7b62 commit 8c0f716

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

radicale/pathutils.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,11 @@ def path_to_filesystem(root: str, sane_path: str) -> str:
282282
for part in parts:
283283
if not is_safe_filesystem_path_component(part):
284284
raise UnsafePathError(part)
285-
safe_path_parent = safe_path
286285
safe_path = os.path.join(safe_path, part)
287286
# Check for conflicting files (e.g. case-insensitive file systems
288287
# or short names on Windows file systems)
289-
if os.path.lexists(safe_path):
290-
with os.scandir(safe_path_parent) as entries:
291-
if part not in (e.name for e in entries):
292-
raise CollidingPathError(part)
288+
if (os.path.lexists(safe_path) and not os.path.realpath(safe_path).endswith(part)):
289+
raise CollidingPathError(part)
293290
return safe_path
294291

295292

0 commit comments

Comments
 (0)