Skip to content

Commit

Permalink
Use _assert_unique when running on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dragly committed Mar 10, 2018
1 parent 2ac21fe commit 18710fb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion exdir/core/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ def thorough(parent_path, name):
name_lower = str(name).lower()
_assert_valid_characters(name_lower)

# NOTE os.listdir is much faster here than os.walk or parent_path.iterdir
if isinstance(pathlib.Path(parent_path), pathlib.WindowsPath):
# use _assert_unique if we're already on Windows, because it is much faster
# than the test below
_assert_unique(parent_path, name)
return

# os.listdir is much faster here than os.walk or parent_path.iterdir
for item in os.listdir(parent_path):
if name_lower == item.lower():
raise FileExistsError(
Expand Down

0 comments on commit 18710fb

Please sign in to comment.