Catch OSError in prune_dirs
Since `fnmatch_all` can raise `OSError`s, and we were already silently
giving up in `prune_dirs` on some of these exception, just do more of
the same.
@@ -283,14 +283,14 @@ def prune_dirs(path, root=None, clutter=('.DS_Store', 'Thumbs.db')):
continue
clutter = [bytestring_path(c) for c in clutter]
match_paths = [bytestring_path(d) for d in os.listdir(directory)]
+ try:
if fnmatch_all(match_paths, clutter):
# Directory contains only clutter (or nothing).
- try:
shutil.rmtree(directory)
- except OSError:
- break
else:
break
+ except OSError:
+ break
def components(path):
