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