1
0
Fork 0
mirror of synced 2024-06-02 15:31:09 -04:00

Allow nonexistent directories to be cleaned

Make nonexistent directories be skipped when cleaning.
This commit is contained in:
Anish Athalye 2015-01-26 10:38:08 -05:00
parent 69502854aa
commit 0b4b79e422

View file

@ -31,6 +31,9 @@ class Cleaner(Executor):
Cleans all the broken symbolic links in target that point to Cleans all the broken symbolic links in target that point to
a subdirectory of the base directory. a subdirectory of the base directory.
''' '''
if not os.path.isdir(os.path.expanduser(target)):
self._log.debug('Ignoring nonexistent directory %s' % target)
return True
for item in os.listdir(os.path.expanduser(target)): for item in os.listdir(os.path.expanduser(target)):
path = os.path.join(os.path.expanduser(target), item) path = os.path.join(os.path.expanduser(target), item)
if not os.path.exists(path) and os.path.islink(path): if not os.path.exists(path) and os.path.islink(path):