diff --git a/lib/clean/user.sh b/lib/clean/user.sh index 0308470..ae44ef8 100644 --- a/lib/clean/user.sh +++ b/lib/clean/user.sh @@ -22,7 +22,7 @@ clean_empty_library_items() { return 0 fi - # 1. Clean top-level empty directories in Library + # 1. Clean top-level empty directories and files in Library local -a empty_dirs=() while IFS= read -r -d '' dir; do [[ -d "$dir" ]] && empty_dirs+=("$dir") @@ -32,6 +32,24 @@ clean_empty_library_items() { safe_clean "${empty_dirs[@]}" "Empty Library folders" fi + # Clean empty files in Library root (skipping .localized and other sentinels) + local -a empty_files=() + while IFS= read -r -d '' file; do + [[ -f "$file" ]] || continue + # Protect .localized and potential system sentinels + if [[ "$(basename "$file")" == ".localized" ]]; then + continue + fi + if is_path_whitelisted "$file"; then + continue + fi + empty_files+=("$file") + done < <(find "$HOME/Library" -mindepth 1 -maxdepth 1 -type f -empty -print0 2> /dev/null) + + if [[ ${#empty_files[@]} -gt 0 ]]; then + safe_clean "${empty_files[@]}" "Empty Library files" + fi + # 2. Clean empty subdirectories in Application Support and other key locations # Iteratively remove empty directories until no more are found local -a key_locations=(