mirror of
https://github.com/tw93/Mole.git
synced 2026-02-15 07:35:07 +00:00
fix: improve uninstall guidance and timeouts
This commit is contained in:
@@ -455,22 +455,32 @@ batch_uninstall_applications() {
|
|||||||
else
|
else
|
||||||
# Fallback to manual removal if brew fails
|
# Fallback to manual removal if brew fails
|
||||||
if [[ "$needs_sudo" == true ]]; then
|
if [[ "$needs_sudo" == true ]]; then
|
||||||
safe_sudo_remove "$app_path" || reason="remove failed"
|
if ! safe_sudo_remove "$app_path"; then
|
||||||
|
reason="brew failed, manual removal failed"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
safe_remove "$app_path" true || reason="remove failed"
|
if ! safe_remove "$app_path" true; then
|
||||||
|
reason="brew failed, manual removal failed"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [[ "$needs_sudo" == true ]]; then
|
elif [[ "$needs_sudo" == true ]]; then
|
||||||
if ! safe_sudo_remove "$app_path"; then
|
if ! safe_sudo_remove "$app_path"; then
|
||||||
local app_owner=$(get_file_owner "$app_path")
|
local app_owner=$(get_file_owner "$app_path")
|
||||||
if [[ -n "$app_owner" && "$app_owner" != "$current_user" && "$app_owner" != "root" ]]; then
|
if [[ -n "$app_owner" && "$app_owner" != "$current_user" && "$app_owner" != "root" ]]; then
|
||||||
reason="owned by $app_owner"
|
reason="owned by $app_owner, try 'sudo chown $(whoami) \"$app_path\"'"
|
||||||
else
|
else
|
||||||
reason="permission denied"
|
reason="permission denied, try 'mole touchid' for passwordless sudo"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
safe_remove "$app_path" true || reason="remove failed"
|
if ! safe_remove "$app_path" true; then
|
||||||
|
if [[ ! -w "$(dirname "$app_path")" ]]; then
|
||||||
|
reason="parent directory not writable"
|
||||||
|
else
|
||||||
|
reason="remove failed, check permissions"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -183,9 +183,21 @@ brew_uninstall_cask() {
|
|||||||
local uninstall_ok=false
|
local uninstall_ok=false
|
||||||
local brew_exit=0
|
local brew_exit=0
|
||||||
|
|
||||||
|
# Calculate timeout based on app size (large apps need more time)
|
||||||
|
local timeout=300 # Default 5 minutes
|
||||||
|
if [[ -n "$app_path" && -d "$app_path" ]]; then
|
||||||
|
local size_gb=$(($(get_path_size_kb "$app_path") / 1048576))
|
||||||
|
if [[ $size_gb -gt 15 ]]; then
|
||||||
|
timeout=900 # 15 minutes for very large apps (Xcode, Adobe, etc.)
|
||||||
|
elif [[ $size_gb -gt 5 ]]; then
|
||||||
|
timeout=600 # 10 minutes for large apps
|
||||||
|
fi
|
||||||
|
debug_log "App size: ${size_gb}GB, timeout: ${timeout}s"
|
||||||
|
fi
|
||||||
|
|
||||||
# Run with timeout to prevent hangs from problematic cask scripts
|
# Run with timeout to prevent hangs from problematic cask scripts
|
||||||
if HOMEBREW_NO_ENV_HINTS=1 HOMEBREW_NO_AUTO_UPDATE=1 NONINTERACTIVE=1 \
|
if HOMEBREW_NO_ENV_HINTS=1 HOMEBREW_NO_AUTO_UPDATE=1 NONINTERACTIVE=1 \
|
||||||
run_with_timeout 300 brew uninstall --cask "$cask_name" 2>&1; then
|
run_with_timeout "$timeout" brew uninstall --cask "$cask_name" 2>&1; then
|
||||||
uninstall_ok=true
|
uninstall_ok=true
|
||||||
else
|
else
|
||||||
brew_exit=$?
|
brew_exit=$?
|
||||||
|
|||||||
Reference in New Issue
Block a user