mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-11-11 00:41:34 +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,
|
# list all directories recursively and sort them by path,
|
||||||
# longest first
|
# longest first
|
||||||
L = sorted(
|
L = sorted(
|
||||||
pathlib_root_dir.glob("**"),
|
pathlib_root_dir.glob("*/*"),
|
||||||
key=lambda p: len(str(p)),
|
key=lambda p: len(str(p)),
|
||||||
reverse=True,
|
reverse=True,
|
||||||
)
|
)
|
||||||
for pdir in L:
|
for pdir in L:
|
||||||
try:
|
try:
|
||||||
pdir.rmdir() # remove directory if empty
|
pdir.rmdir() # remove directory if empty
|
||||||
except OSError:
|
except OSError:
|
||||||
continue # catch and continue if non-empty
|
continue # catch and continue if non-empty
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue