From 0562a245d6d09cc8491993db35ceeb87ccb99b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Reuh=20Fildadut?= Date: Fri, 10 Oct 2025 16:46:15 +0200 Subject: [PATCH] fix: properly remove nested empty directories --- feather.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/feather.py b/feather.py index 12fa8cb..80ee18e 100755 --- a/feather.py +++ b/feather.py @@ -248,10 +248,18 @@ def remove_html_for_item(config, item_json, ignore_deleted=False): def remove_empty_html_directories(config): # Remove empty directories in the HTML directory html_root = config.html_root + removed_directories = set() for (dirpath, dirnames, filenames) in html_root.walk(top_down=False): 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() + removed_directories.add(dirpath) def synchronize(config, client_session): # Do a full feather update