mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-10-29 07:26:25 +08:00
fix for remove orphan to not remove root dir
This commit is contained in:
parent
2df0bf441d
commit
1000f90567
1 changed files with 2 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue