1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 15:39:42 +00:00

Increased protection for databases

This commit is contained in:
Tw93
2025-10-04 18:59:55 +08:00
parent 2929ae5e26
commit 2ddf3280e8
3 changed files with 43 additions and 11 deletions

View File

@@ -51,6 +51,7 @@ mole --help # Show help
```
> 💡 New to terminal? Check [小白使用指南](./GUIDE.md) · Homebrew users: `brew upgrade mole` to update
> ⚠️ **Recommended:** Always run `mole clean --dry-run` first to preview changes before cleanup
## Features
@@ -60,19 +61,19 @@ mole --help # Show help
$ mole clean
▶ System essentials
✓ User app cache (45.2GB) # Caches, logs, trash (20-50GB)
✓ User app cache (45.2GB) # Caches, logs, trash 20-50GB typical
✓ User app logs (2.1GB)
✓ Trash (12.3GB)
▶ Browser cleanup # Chrome, Safari, Arc (5-15GB)
▶ Browser cleanup # Chrome, Safari, Arc 5-15GB typical
✓ Chrome cache (8.4GB)
✓ Safari cache (2.1GB)
▶ Developer tools # npm, Docker, Xcode (15-40GB)
▶ Developer tools # npm, Docker, Xcode 15-40GB typical
✓ Xcode derived data (9.1GB)
✓ Node.js cache (14.2GB)
▶ Others # Cloud, Office, Media (10-40GB)
▶ Others # Cloud, Office, Media 10-40GB typical
✓ Dropbox cache (5.2GB)
✓ Spotify cache (3.1GB)
@@ -105,12 +106,12 @@ $ mole uninstall
🗑️ Uninstalling: Adobe Creative Cloud
✓ Removed application # /Applications/
✓ Cleaned 52 related files # ~/Library/ (12 locations)
✓ Cleaned 52 related files # ~/Library/ across 12 locations
- Support files & caches # Application Support, Caches
- Preferences & logs # Preferences, Logs
- WebKit storage & cookies # WebKit, HTTPStorages
- Extensions & plugins # Internet Plug-Ins, Services
- System files (sudo) # /Library/, Launch daemons
- System files with sudo # /Library/, Launch daemons
====================================================================
🎉 UNINSTALLATION COMPLETE!
@@ -145,10 +146,14 @@ Total: 156.8GB
## FAQ
1. **Will Mole delete important files?** - No. Mole has built-in protection and skips system-critical files.
2. **Can I undo cleanup operations?** - Cache files are safe to delete and will regenerate automatically.
1. **Will Mole delete important files?** - No. Mole has built-in protection for:
- System-critical files like Input Methods, Dock, and System Preferences
- User data from IDEs like JetBrains DataGrip and VS Code, plus database tools
- License data from paid apps like 1Password and Adobe products
- App settings are only removed when you explicitly uninstall the app
2. **Can I undo cleanup operations?** - Cache files are safe to delete and will regenerate automatically. For important data protection, use the whitelist feature via `mole clean --whitelist`.
3. **How often should I run cleanup?** - Once a month is sufficient. Run when disk space is low.
4. **Is it safe to use?** - Yes. The tool previews what will be deleted before any action (`--dry-run`).
4. **Is it safe to use?** - Yes. **Always run `mole clean --dry-run` first** to preview what will be deleted before any action.
## Support

View File

@@ -819,6 +819,29 @@ perform_cleanup() {
fi
done
fi
# Also check for non-com.* folders that may contain user data
for support_dir in ~/Library/Application\ Support/*; do
[[ -d "$support_dir" ]] || continue
local dir_name=$(basename "$support_dir")
# Skip if it starts with com. (already processed) or is in dot directories
[[ "$dir_name" == com.* || "$dir_name" == .* ]] && continue
# CRITICAL: Protect important data folders (JetBrains, database tools, etc.)
if should_protect_data "$dir_name"; then
continue
fi
# Only clean if significant size and looks like app data, but be conservative
# Skip common system/user folders
case "$dir_name" in
"CrashReporter"|"AddressBook"|"CallHistoryDB"|"CallHistoryTransactions"|\
"CloudDocs"|"icdd"|"IdentityServices"|"Mail"|"CallServices"|\
"com.apple."*|"Adobe"|"Google"|"Mozilla"|"Netscape"|"Yahoo"|\
"AddressBook"|"iCloud"|"iLifeMediaBrowser"|"MobileSync"|\
"CallHistory"|"FaceTime"|"Twitter")
# System or commonly used folders, skip
continue
;;
esac
done
echo " ${GREEN}${NC} Complete ($data_count removed)"
# Check for orphaned preferences (with protection for critical system settings)

View File

@@ -332,12 +332,16 @@ readonly DATA_PROTECTED_BUNDLES=(
"com.dashlane.*" # Dashlane
"com.bitwarden.*" # Bitwarden
"com.keepassx.*" # KeePassXC
"com.jetbrains.*" # JetBrains IDEs (dev tools)
"com.jetbrains.*" # JetBrains IDEs (dev tools with user data)
"JetBrains*" # JetBrains Application Support folders
"com.sublimetext.*" # Sublime Text (paid)
"com.panic.transmit*" # Transmit (paid)
"com.sequelpro.*" # Database tools
"com.sequel-ace.*"
"com.tinyapp.*" # TablePlus (paid)
"com.dbeaver.*" # DBeaver (database tool)
"com.navicat.*" # Navicat (database tool)
"com.mongodb.compass" # MongoDB Compass
"com.adobe.*" # Adobe Creative Suite (design tools)
"com.bohemiancoding.*" # Sketch
"com.figma.*" # Figma