mirror of
https://github.com/tw93/Mole.git
synced 2026-02-10 18:54:17 +00:00
Performance and speed optimization
This commit is contained in:
@@ -137,7 +137,7 @@ clean_orphaned_app_data() {
|
||||
fi
|
||||
|
||||
# Check if app exists in our scan
|
||||
if grep -q "^$bundle_id$" "$installed_bundles" 2> /dev/null; then
|
||||
if grep -Fxq "$bundle_id" "$installed_bundles" 2> /dev/null; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -231,7 +231,7 @@ clean_orphaned_app_data() {
|
||||
if is_orphaned "$bundle_id" "$match"; then
|
||||
# Use timeout to prevent du from hanging on network mounts or problematic paths
|
||||
local size_kb
|
||||
size_kb=$(run_with_timeout 5 get_path_size_kb "$match")
|
||||
size_kb=$(get_path_size_kb "$match")
|
||||
if [[ -z "$size_kb" || "$size_kb" == "0" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
@@ -64,7 +64,8 @@ clean_orphaned_casks() {
|
||||
if sudo -n true 2> /dev/null; then
|
||||
if [[ -t 1 ]]; then
|
||||
stop_inline_spinner
|
||||
MOLE_SPINNER_PREFIX=" " start_inline_spinner "Cleaning orphaned casks..."
|
||||
echo -e " ${BLUE}${ICON_ARROW}${NC} Removing orphaned Homebrew casks (may require password for certain apps)"
|
||||
MOLE_SPINNER_PREFIX=" " start_inline_spinner "Cleaning..."
|
||||
fi
|
||||
|
||||
local removed_casks=0
|
||||
@@ -76,7 +77,7 @@ clean_orphaned_casks() {
|
||||
|
||||
if [[ -t 1 ]]; then stop_inline_spinner; fi
|
||||
|
||||
[[ $removed_casks -gt 0 ]] && log_success "Orphaned Homebrew casks ($removed_casks apps)"
|
||||
[[ $removed_casks -gt 0 ]] && echo -e " ${GREEN}${ICON_SUCCESS}${NC} Removed $removed_casks orphaned cask(s)"
|
||||
else
|
||||
# Sudo session expired - inform user to run brew manually
|
||||
if [[ -t 1 ]]; then stop_inline_spinner; fi
|
||||
|
||||
@@ -3,6 +3,22 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Helper function to clean tool caches using their built-in commands
|
||||
# Args: $1 - description, $@ - command to execute
|
||||
# Env: DRY_RUN
|
||||
clean_tool_cache() {
|
||||
local description="$1"
|
||||
shift
|
||||
|
||||
if [[ "$DRY_RUN" != "true" ]]; then
|
||||
if "$@" > /dev/null 2>&1; then
|
||||
echo -e " ${GREEN}${ICON_SUCCESS}${NC} $description"
|
||||
fi
|
||||
else
|
||||
echo -e " ${YELLOW}→${NC} $description (would clean)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Clean npm cache (command + directories)
|
||||
# npm cache clean clears official npm cache, safe_clean handles alternative package managers
|
||||
# Env: DRY_RUN
|
||||
|
||||
@@ -53,7 +53,9 @@ clean_deep_system() {
|
||||
fi
|
||||
|
||||
# Clean orphaned cask records (delegated to clean_brew module)
|
||||
clean_orphaned_casks
|
||||
# DISABLED: This feature triggers password prompts and provides minimal benefit
|
||||
# Users can manually run: brew list --cask && brew uninstall --cask <name>
|
||||
# clean_orphaned_casks
|
||||
|
||||
# Clean macOS Install Data (system upgrade leftovers)
|
||||
# Only remove if older than 30 days to ensure system stability
|
||||
|
||||
Reference in New Issue
Block a user