Commit 64e80d49 by willmcgugan

Added graceful handling of the directory structure changing during a 'walk'.

parent 0bd14855
......@@ -712,6 +712,7 @@ class FS(object):
while dirs:
current_path = dirs.pop()
paths = []
try:
for filename in listdir(current_path):
path = pathjoin(current_path, filename)
if self.isdir(path):
......@@ -720,15 +721,22 @@ class FS(object):
else:
if wildcard(filename):
paths.append(filename)
except ResourceNotFoundError:
# Could happen if another thread / process deletes something whilst we are walking
pass
yield (current_path, paths)
elif search == "depth":
def recurse(recurse_path):
try:
for path in listdir(recurse_path, wildcard=dir_wildcard, full=True, dirs_only=True):
for p in recurse(path):
yield p
except ResourceNotFoundError:
# Could happen if another thread / process deletes something whilst we are walking
pass
yield (recurse_path, self.listdir(recurse_path, wildcard=wildcard, files_only=True))
for p in recurse(path):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment