1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-24 01:30: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

@@ -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
}