Skip to content

Commit

Permalink
children and rchildren updated to check for anchor
Browse files Browse the repository at this point in the history
before checking for local, this fixes and issues that appeared while
working with relative paths
  • Loading branch information
tgbugs committed Jun 24, 2020
1 parent 0d0a0ae commit fd7a895
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions augpathlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,12 @@ def copy_from(self, source, force=False, copy_cache_meta=False):
@property
def children(self):
if self.is_dir():
if self.cache is not None and self == self.cache.anchor.local:
if (self.cache is not None and
# relative paths inside may have a cache but no anchor
# the anchor itself can be relative and have an anchor
# so we test to see if there is an anchor first
self.cache.anchor and
self == self.cache.anchor.local):
cache_ignore = self._cache_class.cache_ignore
# implemented this way we can still use Path to navigate
# once we are inside local data dir, though all files there
Expand All @@ -1191,7 +1196,12 @@ def children(self):

@property
def rchildren(self):
if self.is_dir() and self.cache is not None and self == self.cache.anchor.local:
if (self.is_dir() and self.cache is not None and
# relative paths inside may have a cache but no anchor
# the anchor itself can be relative and have an anchor
# so we test to see if there is an anchor first
self.cache.anchor and
self == self.cache.anchor.local):
for path in self.children:
yield path
yield from path.rchildren
Expand Down

0 comments on commit fd7a895

Please sign in to comment.