1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 11:31:46 +00:00

refactor: optimize raycast cleanup code structure

Improve code readability and maintainability:
- Simplify conditional logic with chained operators
- Add clarifying comments for different cleanup scopes
- Rename variables for better semantic clarity
- Maintain consistent style with other app cleanup patterns
This commit is contained in:
tw93
2026-02-03 14:53:10 +08:00
parent 4f3eb0eb62
commit a5c7abd227

View File

@@ -1093,28 +1093,28 @@ find_app_files() {
# 7. Raycast # 7. Raycast
if [[ "$bundle_id" == "com.raycast.macos" ]]; then if [[ "$bundle_id" == "com.raycast.macos" ]]; then
local raycast_parents=( # Standard user directories
local raycast_dirs=(
"$HOME/Library/Application Support" "$HOME/Library/Application Support"
"$HOME/Library/Application Scripts" "$HOME/Library/Application Scripts"
"$HOME/Library/Containers" "$HOME/Library/Containers"
) )
for parent in "${raycast_parents[@]}"; do for dir in "${raycast_dirs[@]}"; do
[[ -d "$parent" ]] || continue [[ -d "$dir" ]] && while IFS= read -r -d '' p; do
while IFS= read -r -d '' p; do
files_to_clean+=("$p") files_to_clean+=("$p")
done < <(command find "$parent" -maxdepth 1 -type d -iname "*raycast*" -print0 2> /dev/null) done < <(command find "$dir" -maxdepth 1 -type d -iname "*raycast*" -print0 2> /dev/null)
done done
if [[ -d "$HOME/Library/Caches" ]]; then
while IFS= read -r -d '' p; do # Cache (deeper search)
files_to_clean+=("$p") [[ -d "$HOME/Library/Caches" ]] && while IFS= read -r -d '' p; do
done < <(command find "$HOME/Library/Caches" -maxdepth 2 -type d -iname "*raycast*" -print0 2> /dev/null) files_to_clean+=("$p")
fi done < <(command find "$HOME/Library/Caches" -maxdepth 2 -type d -iname "*raycast*" -print0 2> /dev/null)
local code_storage="$HOME/Library/Application Support/Code/User/globalStorage"
if [[ -d "$code_storage" ]]; then # VSCode extension storage
while IFS= read -r -d '' p; do local vscode_global="$HOME/Library/Application Support/Code/User/globalStorage"
files_to_clean+=("$p") [[ -d "$vscode_global" ]] && while IFS= read -r -d '' p; do
done < <(command find "$code_storage" -maxdepth 1 -type d -iname "*raycast*" -print0 2> /dev/null) files_to_clean+=("$p")
fi done < <(command find "$vscode_global" -maxdepth 1 -type d -iname "*raycast*" -print0 2> /dev/null)
fi fi
# Output results # Output results
@@ -1210,9 +1210,9 @@ find_app_system_files() {
done < <(command find /private/var/db/receipts -maxdepth 1 \( -name "*$bundle_id*" \) -print0 2> /dev/null) done < <(command find /private/var/db/receipts -maxdepth 1 \( -name "*$bundle_id*" \) -print0 2> /dev/null)
fi fi
# Raycast system-level (*raycast* under /Library/Application Support) # Raycast system-level files
if [[ "$bundle_id" == "com.raycast.macos" && -d "/Library/Application Support" ]]; then if [[ "$bundle_id" == "com.raycast.macos" ]]; then
while IFS= read -r -d '' p; do [[ -d "/Library/Application Support" ]] && while IFS= read -r -d '' p; do
system_files+=("$p") system_files+=("$p")
done < <(command find "/Library/Application Support" -maxdepth 1 -type d -iname "*raycast*" -print0 2> /dev/null) done < <(command find "/Library/Application Support" -maxdepth 1 -type d -iname "*raycast*" -print0 2> /dev/null)
fi fi