1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 13:16:47 +00:00

Fix the problems of remove and reinstall

This commit is contained in:
Tw93
2025-12-29 15:51:15 +08:00
parent c1e7290f4d
commit c5910224ae
2 changed files with 29 additions and 11 deletions

View File

@@ -236,6 +236,19 @@ check_requirements() {
# Check if already installed via Homebrew
if command -v brew > /dev/null 2>&1 && brew list mole > /dev/null 2>&1; then
# Verify that mole executable actually exists and is from Homebrew
local mole_path
mole_path=$(command -v mole 2> /dev/null || true)
local is_homebrew_binary=false
if [[ -n "$mole_path" && -L "$mole_path" ]]; then
if readlink "$mole_path" | grep -q "Cellar/mole"; then
is_homebrew_binary=true
fi
fi
# Only block installation if Homebrew binary actually exists
if [[ "$is_homebrew_binary" == "true" ]]; then
if [[ "$ACTION" == "update" ]]; then
return 0
fi
@@ -244,9 +257,14 @@ check_requirements() {
echo ""
echo "Choose one:"
echo -e " 1. Update via Homebrew: ${GREEN}brew upgrade mole${NC}"
echo -e " 2. Switch to manual: ${GREEN}brew uninstall mole${NC} then re-run this"
echo -e " 2. Switch to manual: ${GREEN}brew uninstall --force mole${NC} then re-run this"
echo ""
exit 1
else
# Brew has mole in database but binary doesn't exist - clean up
log_warning "Cleaning up stale Homebrew installation..."
brew uninstall --force mole > /dev/null 2>&1 || true
fi
fi
# Check if install directory exists and is writable

4
mole
View File

@@ -25,7 +25,7 @@ source "$SCRIPT_DIR/lib/core/common.sh"
trap cleanup_temp_files EXIT INT TERM
# Version info
VERSION="1.15.7"
VERSION="1.15.8"
MOLE_TAGLINE="Deep clean and optimize your Mac."
# Check TouchID configuration
@@ -557,7 +557,7 @@ remove_mole() {
# Remove Homebrew installation (silent)
local has_error=false
if [[ "$is_homebrew" == "true" ]]; then
if ! brew uninstall mole > /dev/null 2>&1; then
if ! brew uninstall --force mole > /dev/null 2>&1; then
has_error=true
fi
fi