mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 15:39:42 +00:00
fix: Refine recent items clearing to target specific global lists and prevent accidental deletion
This commit is contained in:
@@ -96,25 +96,33 @@ opt_log_cleanup() {
|
|||||||
opt_recent_items() {
|
opt_recent_items() {
|
||||||
echo -e "${BLUE}${ICON_ARROW}${NC} Clearing recent items lists..."
|
echo -e "${BLUE}${ICON_ARROW}${NC} Clearing recent items lists..."
|
||||||
local shared_dir="$HOME/Library/Application Support/com.apple.sharedfilelist"
|
local shared_dir="$HOME/Library/Application Support/com.apple.sharedfilelist"
|
||||||
|
|
||||||
|
# Target only the global recent item lists to avoid touching per-app/System Settings SFL files (Issue #136)
|
||||||
|
local -a recent_lists=(
|
||||||
|
"$shared_dir/com.apple.LSSharedFileList.RecentApplications.sfl2"
|
||||||
|
"$shared_dir/com.apple.LSSharedFileList.RecentDocuments.sfl2"
|
||||||
|
"$shared_dir/com.apple.LSSharedFileList.RecentServers.sfl2"
|
||||||
|
"$shared_dir/com.apple.LSSharedFileList.RecentHosts.sfl2"
|
||||||
|
"$shared_dir/com.apple.LSSharedFileList.RecentApplications.sfl"
|
||||||
|
"$shared_dir/com.apple.LSSharedFileList.RecentDocuments.sfl"
|
||||||
|
"$shared_dir/com.apple.LSSharedFileList.RecentServers.sfl"
|
||||||
|
"$shared_dir/com.apple.LSSharedFileList.RecentHosts.sfl"
|
||||||
|
)
|
||||||
|
|
||||||
if [[ -d "$shared_dir" ]]; then
|
if [[ -d "$shared_dir" ]]; then
|
||||||
# Use safe removal with protection checks instead of find -delete
|
|
||||||
# This prevents accidental deletion of System Settings files
|
|
||||||
local deleted=0
|
local deleted=0
|
||||||
while IFS= read -r -d '' sfl_file; do
|
for sfl_file in "${recent_lists[@]}"; do
|
||||||
# Check if file should be protected (System Settings, etc.)
|
# Skip missing files and any protected paths
|
||||||
|
[[ -e "$sfl_file" ]] || continue
|
||||||
if should_protect_path "$sfl_file"; then
|
if should_protect_path "$sfl_file"; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if safe_remove "$sfl_file" true; then
|
if safe_remove "$sfl_file" true; then
|
||||||
((deleted++))
|
((deleted++))
|
||||||
fi
|
fi
|
||||||
done < <(command find "$shared_dir" -maxdepth 5 -name "*.sfl2" -type f -print0 2> /dev/null)
|
done
|
||||||
|
|
||||||
if [[ $deleted -gt 0 ]]; then
|
echo -e "${GREEN}${ICON_SUCCESS}${NC} Shared file lists cleared${deleted:+ ($deleted files)}"
|
||||||
echo -e "${GREEN}${ICON_SUCCESS}${NC} Shared file lists cleared ($deleted files)"
|
|
||||||
else
|
|
||||||
echo -e "${GREEN}${ICON_SUCCESS}${NC} Shared file lists cleared"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f "$HOME/Library/Preferences/com.apple.recentitems.plist" 2> /dev/null || true
|
rm -f "$HOME/Library/Preferences/com.apple.recentitems.plist" 2> /dev/null || true
|
||||||
|
|||||||
2
mole
2
mole
@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
source "$SCRIPT_DIR/lib/core/common.sh"
|
source "$SCRIPT_DIR/lib/core/common.sh"
|
||||||
|
|
||||||
# Version info
|
# Version info
|
||||||
VERSION="1.13.11"
|
VERSION="1.13.12"
|
||||||
MOLE_TAGLINE="Deep clean and optimize your Mac."
|
MOLE_TAGLINE="Deep clean and optimize your Mac."
|
||||||
|
|
||||||
# Check TouchID configuration
|
# Check TouchID configuration
|
||||||
|
|||||||
Reference in New Issue
Block a user