1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 15:39:42 +00:00

fix: optimize find command expressions in scan_purge_targets function

This commit is contained in:
tw93
2026-02-02 11:21:11 +08:00
parent 7514680e6b
commit 67c9d16b13

View File

@@ -416,20 +416,20 @@ scan_purge_targets() {
local prune_expr=() local prune_expr=()
for i in "${!prune_dirs[@]}"; do for i in "${!prune_dirs[@]}"; do
prune_expr+=( -name "${prune_dirs[$i]}" ) prune_expr+=(-name "${prune_dirs[$i]}")
[[ $i -lt $((${#prune_dirs[@]} - 1)) ]] && prune_expr+=( -o ) [[ $i -lt $((${#prune_dirs[@]} - 1)) ]] && prune_expr+=(-o)
done done
local target_expr=() local target_expr=()
for i in "${!purge_targets[@]}"; do for i in "${!purge_targets[@]}"; do
target_expr+=( -name "${purge_targets[$i]}" -print ) target_expr+=(-name "${purge_targets[$i]}")
[[ $i -lt $((${#purge_targets[@]} - 1)) ]] && target_expr+=( -o ) [[ $i -lt $((${#purge_targets[@]} - 1)) ]] && target_expr+=(-o)
done done
command find "$search_path" -mindepth "$min_depth" -maxdepth "$max_depth" -type d \ command find "$search_path" -mindepth "$min_depth" -maxdepth "$max_depth" -type d \
\( "${prune_expr[@]}" \) -prune -o \ \( "${prune_expr[@]}" \) -prune -o \
\( "${target_expr[@]}" \) \ \( "${target_expr[@]}" \) -print -prune \
2>&1 | tee "$output_file.raw" > /dev/null 2> /dev/null > "$output_file.raw" || true
process_scan_results "$output_file.raw" process_scan_results "$output_file.raw"
fi fi