mirror of
https://github.com/tw93/Mole.git
synced 2026-02-11 06:34:21 +00:00
Application scanning optimization
This commit is contained in:
@@ -113,30 +113,49 @@ clean_orphaned_app_data() {
|
|||||||
local c="${spinner_chars:$((i % 4)):1}"
|
local c="${spinner_chars:$((i % 4)):1}"
|
||||||
echo -ne "\r\033[K $c Scanning installed apps... $count found" >&2
|
echo -ne "\r\033[K $c Scanning installed apps... $count found" >&2
|
||||||
((i++))
|
((i++))
|
||||||
sleep 0.2 2> /dev/null || sleep 1
|
sleep 0.1
|
||||||
done
|
done
|
||||||
) &
|
) &
|
||||||
local spinner_pid=$!
|
local spinner_pid=$!
|
||||||
|
|
||||||
# Parallel scan for applications with increased timeout for large app directories
|
# Parallel scan for applications
|
||||||
local pids=()
|
local pids=()
|
||||||
local dir_idx=0
|
local dir_idx=0
|
||||||
for app_dir in "${app_dirs[@]}"; do
|
for app_dir in "${app_dirs[@]}"; do
|
||||||
[[ -d "$app_dir" ]] || continue
|
[[ -d "$app_dir" ]] || continue
|
||||||
(
|
(
|
||||||
# Increased timeout to 30s to handle large app directories (especially /System/Applications)
|
# Quickly find all .app bundles first
|
||||||
# Timeout errors are suppressed to prevent confusing output
|
local -a app_paths=()
|
||||||
run_with_timeout 30 sh -c "find '$app_dir' -name '*.app' -maxdepth 3 -type d 2> /dev/null" 2> /dev/null | while IFS= read -r app_path; do
|
while IFS= read -r app_path; do
|
||||||
local bundle_id
|
[[ -n "$app_path" ]] && app_paths+=("$app_path")
|
||||||
bundle_id=$(defaults read "$app_path/Contents/Info.plist" CFBundleIdentifier 2> /dev/null || echo "")
|
done < <(find "$app_dir" -name '*.app' -maxdepth 3 -type d 2> /dev/null)
|
||||||
|
|
||||||
|
# Read bundle IDs with PlistBuddy
|
||||||
|
local count=0
|
||||||
|
for app_path in "${app_paths[@]}"; do
|
||||||
|
local plist_path="$app_path/Contents/Info.plist"
|
||||||
|
[[ ! -f "$plist_path" ]] && continue
|
||||||
|
|
||||||
|
local bundle_id=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$plist_path" 2> /dev/null || echo "")
|
||||||
|
|
||||||
if [[ -n "$bundle_id" ]]; then
|
if [[ -n "$bundle_id" ]]; then
|
||||||
echo "$bundle_id"
|
echo "$bundle_id"
|
||||||
# Update progress count atomically
|
((count++))
|
||||||
local current_count=$(cat "$progress_count_file" 2> /dev/null || echo "0")
|
|
||||||
echo "$((current_count + 1))" > "$progress_count_file"
|
# Batch update progress every 10 apps to reduce I/O
|
||||||
|
if [[ $((count % 10)) -eq 0 ]]; then
|
||||||
|
local current=$(cat "$progress_count_file" 2> /dev/null || echo "0")
|
||||||
|
echo "$((current + 10))" > "$progress_count_file"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done > "$scan_tmp_dir/apps_${dir_idx}.txt"
|
done
|
||||||
) &
|
|
||||||
|
# Final progress update
|
||||||
|
if [[ $((count % 10)) -ne 0 ]]; then
|
||||||
|
local current=$(cat "$progress_count_file" 2> /dev/null || echo "0")
|
||||||
|
echo "$((current + count % 10))" > "$progress_count_file"
|
||||||
|
fi
|
||||||
|
) > "$scan_tmp_dir/apps_${dir_idx}.txt" &
|
||||||
pids+=($!)
|
pids+=($!)
|
||||||
((dir_idx++))
|
((dir_idx++))
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -126,8 +126,7 @@ start_inline_spinner() {
|
|||||||
# Output to stderr to avoid interfering with stdout
|
# Output to stderr to avoid interfering with stdout
|
||||||
printf "\r${MOLE_SPINNER_PREFIX:-}${BLUE}%s${NC} %s" "$c" "$message" >&2 || exit 0
|
printf "\r${MOLE_SPINNER_PREFIX:-}${BLUE}%s${NC} %s" "$c" "$message" >&2 || exit 0
|
||||||
((i++))
|
((i++))
|
||||||
# macOS supports decimal sleep, this is the primary target
|
sleep 0.1
|
||||||
sleep 0.1 2> /dev/null || sleep 1 2> /dev/null || exit 0
|
|
||||||
done
|
done
|
||||||
) &
|
) &
|
||||||
INLINE_SPINNER_PID=$!
|
INLINE_SPINNER_PID=$!
|
||||||
|
|||||||
2
mole
2
mole
@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
source "$SCRIPT_DIR/lib/core/common.sh"
|
source "$SCRIPT_DIR/lib/core/common.sh"
|
||||||
|
|
||||||
# Version info
|
# Version info
|
||||||
VERSION="1.12.4"
|
VERSION="1.12.5"
|
||||||
MOLE_TAGLINE="can dig deep to clean your Mac."
|
MOLE_TAGLINE="can dig deep to clean your Mac."
|
||||||
|
|
||||||
# Check if Touch ID is already configured
|
# Check if Touch ID is already configured
|
||||||
|
|||||||
Reference in New Issue
Block a user