mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 23:05:08 +00:00
fix brew uninstall fallback consistency
This commit is contained in:
@@ -530,15 +530,35 @@ batch_uninstall_applications() {
|
||||
if brew_uninstall_cask "$cask_name" "$app_path"; then
|
||||
used_brew_successfully=true
|
||||
else
|
||||
# Fallback to manual removal if brew fails
|
||||
if [[ "$needs_sudo" == true ]]; then
|
||||
if ! safe_sudo_remove "$app_path"; then
|
||||
reason="brew failed, manual removal failed"
|
||||
# Only fall back to manual app removal when Homebrew no longer
|
||||
# tracks the cask. Otherwise we would recreate the mismatch
|
||||
# where brew still reports the app as installed after Mole
|
||||
# removes the bundle manually.
|
||||
local cask_state=2
|
||||
if command -v is_brew_cask_installed > /dev/null 2>&1; then
|
||||
if is_brew_cask_installed "$cask_name"; then
|
||||
cask_state=0
|
||||
else
|
||||
cask_state=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $cask_state -eq 1 ]]; then
|
||||
if [[ "$needs_sudo" == true ]]; then
|
||||
if ! safe_sudo_remove "$app_path"; then
|
||||
reason="brew cleanup incomplete, manual removal failed"
|
||||
fi
|
||||
else
|
||||
if ! safe_remove "$app_path" true; then
|
||||
reason="brew cleanup incomplete, manual removal failed"
|
||||
fi
|
||||
fi
|
||||
elif [[ $cask_state -eq 0 ]]; then
|
||||
reason="brew uninstall failed, package still installed"
|
||||
suggestion="Run brew uninstall --cask --zap $cask_name"
|
||||
else
|
||||
if ! safe_remove "$app_path" true; then
|
||||
reason="brew failed, manual removal failed"
|
||||
fi
|
||||
reason="brew uninstall failed, package state unknown"
|
||||
suggestion="Run brew uninstall --cask --zap $cask_name"
|
||||
fi
|
||||
fi
|
||||
elif [[ "$needs_sudo" == true ]]; then
|
||||
|
||||
Reference in New Issue
Block a user