fix for remove orphan to not remove root dir

This commit is contained in:
Jon 2021-09-26 22:03:44 -04:00
parent 2df0bf441d
commit 1000f90567
No known key found for this signature in database
GPG key ID: 9665BA6CF5DC2671

View file

@ -161,13 +161,13 @@ def remove_empty_directories(pathlib_root_dir):
# list all directories recursively and sort them by path,
# longest first
L = sorted(
pathlib_root_dir.glob("**"),
pathlib_root_dir.glob("*/*"),
key=lambda p: len(str(p)),
reverse=True,
)
for pdir in L:
try:
pdir.rmdir() # remove directory if empty
pdir.rmdir() # remove directory if empty
except OSError:
continue # catch and continue if non-empty