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

Fix remove permission issue

This commit is contained in:
Tw93
2025-10-15 19:23:13 +08:00
parent 4a0a011d49
commit 2aea2c752c

24
mole
View File

@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/common.sh"
# Version info
VERSION="1.7.14"
VERSION="1.7.15"
MOLE_TAGLINE="can dig deep to clean your Mac."
# Get latest version from remote repository
@@ -366,18 +366,34 @@ remove_mole() {
has_error=true
fi
fi
# Remove manual installations (silent)
# Remove manual installations
if [[ ${manual_count:-0} -gt 0 ]]; then
for install in "${manual_installs[@]}"; do
if [[ -f "$install" ]]; then
rm -f "$install" 2> /dev/null || has_error=true
# Check if directory requires sudo (deletion is a directory operation)
if [[ ! -w "$(dirname "$install")" ]]; then
# Requires sudo
if ! sudo rm -f "$install" 2> /dev/null; then
has_error=true
fi
else
# Regular user permission
if ! rm -f "$install" 2> /dev/null; then
has_error=true
fi
fi
fi
done
fi
if [[ ${alias_count:-0} -gt 0 ]]; then
for alias in "${alias_installs[@]}"; do
if [[ -f "$alias" ]]; then
rm -f "$alias" 2> /dev/null || true
# Check if directory requires sudo
if [[ ! -w "$(dirname "$alias")" ]]; then
sudo rm -f "$alias" 2> /dev/null || true
else
rm -f "$alias" 2> /dev/null || true
fi
fi
done
fi