Skip to content

Commit

Permalink
fixes for case-insensitive file systems
Browse files Browse the repository at this point in the history
  • Loading branch information
berquist committed Jun 9, 2024
1 parent e08279b commit 7e400d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion exdir/core/exdir_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(self, directory, mode=None, allow_remove=False,
# correct checks for the requested mode.
if name_validation != validation.none:
already_exists = validation.path_already_exists_case_insensitive(
directory.parent, directory.name.lower()
str(directory.parent), directory.name.lower()
)
else:
already_exists = directory.exists()
Expand Down
4 changes: 2 additions & 2 deletions exdir/core/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _assert_unique(parent_path, name):
except UnicodeEncodeError:
name = name.encode('utf8')

if path_already_exists_case_insensitive(parent_path, name.lower()):
if path_already_exists_case_insensitive(str(parent_path), name.lower()):
raise RuntimeError(
"A directory with name (case independent) '{}' already exists "
" and cannot be made according to the naming rule 'thorough'.".format(name)
Expand Down Expand Up @@ -128,7 +128,7 @@ def none(parent_path, name):

def path_already_exists_case_insensitive(parent_path, name_lower):
# os.listdir is much faster here than os.walk or parent_path.iterdir
for item in os.listdir(str(parent_path)):
for item in os.listdir(parent_path):
if name_lower == item.lower():
return True
return False

0 comments on commit 7e400d2

Please sign in to comment.