1
0
Fork 0
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:
Étienne Fildadut 2025-10-10 16:46:15 +02:00
parent c576ed7de2
commit 0562a245d6

View file

@ -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