Only perform case-insensitive search if needed
This commit is contained in:
parent
e420074c83
commit
b166172d10
1 changed files with 7 additions and 2 deletions
|
|
@ -35,10 +35,15 @@ def case_insensitive_search(path, item):
|
||||||
|
|
||||||
def find_path(path):
|
def find_path(path):
|
||||||
"""Find path case-insensitively, returns pathlib.Path obj."""
|
"""Find path case-insensitively, returns pathlib.Path obj."""
|
||||||
parts = pathlib.Path(path).resolve().relative_to('/').parts
|
path_obj = pathlib.Path(path).resolve()
|
||||||
real_path = '/'
|
|
||||||
|
# Quick check first
|
||||||
|
if path_obj.exists():
|
||||||
|
return path_obj
|
||||||
|
|
||||||
# Fix case
|
# Fix case
|
||||||
|
parts = path_obj.relative_to('/').parts
|
||||||
|
real_path = '/'
|
||||||
for part in parts:
|
for part in parts:
|
||||||
try:
|
try:
|
||||||
real_path = case_insensitive_search(real_path, part)
|
real_path = case_insensitive_search(real_path, part)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue