1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 20:15:07 +00:00

fix: temporarily disable pipefail to prevent process substitution failures during cleanup operations

This commit is contained in:
Tw93
2026-02-27 22:52:38 +08:00
parent a9433e4acd
commit 013549ad25
4 changed files with 58 additions and 0 deletions

View File

@@ -793,6 +793,12 @@ clean_application_support_logs() {
[[ "$total_apps" =~ ^[0-9]+$ ]] || total_apps=0
local last_progress_update
last_progress_update=$(get_epoch_seconds)
# Temporarily disable pipefail to prevent process substitution failures from interrupting the scan
local pipefail_was_set=false
if [[ -o pipefail ]]; then
pipefail_was_set=true
set +o pipefail
fi
for app_dir in ~/Library/Application\ Support/*; do
[[ -d "$app_dir" ]] || continue
local app_name
@@ -917,6 +923,10 @@ clean_application_support_logs() {
fi
done
done
# Restore pipefail if it was previously set
if [[ "$pipefail_was_set" == "true" ]]; then
set -o pipefail
fi
eval "$_ng_state"
stop_section_spinner
if [[ "$found_any" == "true" ]]; then

View File

@@ -434,6 +434,13 @@ safe_find_delete() {
find_args+=("-mtime" "+$age_days")
fi
# Temporarily disable pipefail to prevent process substitution failures from interrupting
local pipefail_was_set=false
if [[ -o pipefail ]]; then
pipefail_was_set=true
set +o pipefail
fi
# Iterate results to respect should_protect_path
while IFS= read -r -d '' match; do
if should_protect_path "$match"; then
@@ -442,6 +449,11 @@ safe_find_delete() {
safe_remove "$match" true || true
done < <(command find "$base_dir" "${find_args[@]}" -print0 2> /dev/null || true)
# Restore pipefail if it was previously set
if [[ "$pipefail_was_set" == "true" ]]; then
set -o pipefail
fi
return 0
}
@@ -481,6 +493,13 @@ safe_sudo_find_delete() {
find_args+=("-mtime" "+$age_days")
fi
# Temporarily disable pipefail to prevent process substitution failures from interrupting
local pipefail_was_set=false
if [[ -o pipefail ]]; then
pipefail_was_set=true
set +o pipefail
fi
# Iterate results to respect should_protect_path
while IFS= read -r -d '' match; do
if should_protect_path "$match"; then
@@ -489,6 +508,11 @@ safe_sudo_find_delete() {
safe_sudo_remove "$match" || true
done < <(sudo find "$base_dir" "${find_args[@]}" -print0 2> /dev/null || true)
# Restore pipefail if it was previously set
if [[ "$pipefail_was_set" == "true" ]]; then
set -o pipefail
fi
return 0
}

View File

@@ -11,6 +11,13 @@ fix_broken_preferences() {
local broken_count=0
# Temporarily disable pipefail to prevent process substitution failures from interrupting
local pipefail_was_set=false
if [[ -o pipefail ]]; then
pipefail_was_set=true
set +o pipefail
fi
while IFS= read -r plist_file; do
[[ -f "$plist_file" ]] || continue
@@ -49,5 +56,10 @@ fix_broken_preferences() {
done < <(command find "$byhost_dir" -name "*.plist" -type f 2> /dev/null || true)
fi
# Restore pipefail if it was previously set
if [[ "$pipefail_was_set" == "true" ]]; then
set -o pipefail
fi
echo "$broken_count"
}

View File

@@ -191,12 +191,24 @@ opt_saved_state_cleanup() {
local state_dir="$HOME/Library/Saved Application State"
if [[ -d "$state_dir" ]]; then
# Temporarily disable pipefail to prevent process substitution failures from interrupting
local pipefail_was_set=false
if [[ -o pipefail ]]; then
pipefail_was_set=true
set +o pipefail
fi
while IFS= read -r -d '' state_path; do
if should_protect_path "$state_path"; then
continue
fi
safe_remove "$state_path" true > /dev/null 2>&1 || true
done < <(command find "$state_dir" -type d -name "*.savedState" -mtime "+$MOLE_SAVED_STATE_AGE_DAYS" -print0 2> /dev/null)
# Restore pipefail if it was previously set
if [[ "$pipefail_was_set" == "true" ]]; then
set -o pipefail
fi
fi
opt_msg "App saved states optimized"