mirror of
https://codeberg.org/Reuh/feather.git
synced 2025-10-27 18:19:32 +00:00
fix: properly remove nested empty directories
This commit is contained in:
parent
c576ed7de2
commit
0562a245d6
1 changed files with 9 additions and 1 deletions
10
feather.py
10
feather.py
|
|
@ -248,10 +248,18 @@ def remove_html_for_item(config, item_json, ignore_deleted=False):
|
||||||
def remove_empty_html_directories(config):
|
def remove_empty_html_directories(config):
|
||||||
# Remove empty directories in the HTML directory
|
# Remove empty directories in the HTML directory
|
||||||
html_root = config.html_root
|
html_root = config.html_root
|
||||||
|
removed_directories = set()
|
||||||
for (dirpath, dirnames, filenames) in html_root.walk(top_down=False):
|
for (dirpath, dirnames, filenames) in html_root.walk(top_down=False):
|
||||||
if dirpath != html_root:
|
if dirpath != html_root:
|
||||||
if len(dirnames) == 0 and len(filenames) == 0:
|
is_empty = len(filenames) == 0
|
||||||
|
if is_empty and len(dirnames) > 0: # some subdirectories may have been removed in an earlier iteration
|
||||||
|
for subdirname in dirnames:
|
||||||
|
if dirpath / subdirname not in removed_directories:
|
||||||
|
is_empty = False
|
||||||
|
break
|
||||||
|
if is_empty:
|
||||||
dirpath.rmdir()
|
dirpath.rmdir()
|
||||||
|
removed_directories.add(dirpath)
|
||||||
|
|
||||||
def synchronize(config, client_session):
|
def synchronize(config, client_session):
|
||||||
# Do a full feather update
|
# Do a full feather update
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue