##// END OF EJS Templates
icasefs: retry directory scan once for already invalidated cache...
FUJIWARA Katsunori -
r15709:a1f4bd47 default
parent child Browse files
Show More
@@ -630,6 +630,13 b' def fspath(name, root):'
630 if not os.path.lexists(os.path.join(root, name)):
630 if not os.path.lexists(os.path.join(root, name)):
631 return None
631 return None
632
632
633 def find(p, contents):
634 lenp = len(p)
635 for n in contents:
636 if lenp == len(n) and normcase(n) == p:
637 return n
638 return None
639
633 seps = os.sep
640 seps = os.sep
634 if os.altsep:
641 if os.altsep:
635 seps = seps + os.altsep
642 seps = seps + os.altsep
@@ -643,18 +650,19 b' def fspath(name, root):'
643 result.append(sep)
650 result.append(sep)
644 continue
651 continue
645
652
646 if dir not in _fspathcache:
653 contents = _fspathcache.get(dir, None)
647 _fspathcache[dir] = os.listdir(dir)
654 if contents is None:
648 contents = _fspathcache[dir]
655 contents = os.listdir(dir)
656 _fspathcache[dir] = contents
649
657
650 lenp = len(part)
658 found = find(part, contents)
651 for n in contents:
659 if not found:
652 if lenp == len(n) and normcase(n) == part:
660 # retry once for the corner case: add files after dir walking
653 result.append(n)
661 contents = os.listdir(dir)
654 break
662 _fspathcache[dir] = contents
655 else:
663 found = find(part, contents)
656 # Cannot happen, as the file exists!
664
657 result.append(part)
665 result.append(found or part)
658 dir = os.path.join(dir, part)
666 dir = os.path.join(dir, part)
659
667
660 return ''.join(result)
668 return ''.join(result)
General Comments 0
You need to be logged in to leave comments. Login now