mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 11:31:46 +00:00
🐛 Optimize uninstallation of mole
This commit is contained in:
19
install.sh
19
install.sh
@@ -402,19 +402,20 @@ uninstall_mole() {
|
||||
# Only allow removal of mole-specific directories
|
||||
local is_safe=0
|
||||
|
||||
# Safe patterns: must end with 'mole' or be in user's home .config
|
||||
if [[ "$CONFIG_DIR" == "$HOME/.config/mole" ]] ||
|
||||
[[ "$CONFIG_DIR" == "$HOME"/.*/mole ]] ||
|
||||
[[ "$CONFIG_DIR" == */mole ]]; then
|
||||
is_safe=1
|
||||
fi
|
||||
|
||||
# Additional safety: never delete system critical paths
|
||||
# Additional safety: never delete system critical paths (check first)
|
||||
case "$CONFIG_DIR" in
|
||||
/|/usr|/usr/local|/usr/local/bin|/usr/local/lib|/usr/local/share|\
|
||||
/Library|/System|/bin|/sbin|/etc|/var|/opt|"$HOME"|"$HOME/Library")
|
||||
/Library|/System|/bin|/sbin|/etc|/var|/opt|"$HOME"|"$HOME/Library"|\
|
||||
/usr/local/lib/*|/usr/local/share/*|/Library/*|/System/*)
|
||||
is_safe=0
|
||||
;;
|
||||
*)
|
||||
# Safe patterns: must be in user's home and end with 'mole'
|
||||
if [[ "$CONFIG_DIR" == "$HOME/.config/mole" ]] ||
|
||||
[[ "$CONFIG_DIR" == "$HOME"/.*/mole ]]; then
|
||||
is_safe=1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# Ask before removing config directory
|
||||
|
||||
11
mole
11
mole
@@ -332,14 +332,17 @@ remove_mole() {
|
||||
done
|
||||
fi
|
||||
|
||||
# Clean up configuration and cache (both methods)
|
||||
if [[ -d "$HOME/.config/mole" ]]; then
|
||||
rm -rf "$HOME/.config/mole" 2>/dev/null && log_success "Removed configuration"
|
||||
fi
|
||||
# Clean up cache first (logs to config)
|
||||
if [[ -d "$HOME/.cache/mole" ]]; then
|
||||
rm -rf "$HOME/.cache/mole" 2>/dev/null && log_success "Removed cache"
|
||||
fi
|
||||
|
||||
# Clean up configuration last (contains logs)
|
||||
if [[ -d "$HOME/.config/mole" ]]; then
|
||||
log_success "Removed configuration"
|
||||
rm -rf "$HOME/.config/mole" 2>/dev/null
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}✨ Mole has been removed successfully${NC}"
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user