From ba2103d7c012f9e2a6ee00c244ec2bc5b298cdef Mon Sep 17 00:00:00 2001 From: Para Dox Date: Sun, 27 Apr 2025 17:50:03 +0700 Subject: [PATCH] new era --- scripts/prune-reth.sh | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/scripts/prune-reth.sh b/scripts/prune-reth.sh index e54e4529..18cfa19d 100755 --- a/scripts/prune-reth.sh +++ b/scripts/prune-reth.sh @@ -82,7 +82,8 @@ for group_name in "${group_names[@]}"; do echo "Processing group '$group_name' with $num_files ranges." # Use an associative array to track which base paths to keep (for efficient lookup) - declare -A files_to_keep + # We will use the basename as the key to avoid potential issues with '/' in the full path key + declare -A files_to_keep_basenames # Use a standard array to store base paths to move files_to_move=() @@ -90,13 +91,12 @@ for group_name in "${group_names[@]}"; do # Rule 1: Always keep the _0_499999 range if it exists first_range_kept=false for base in "${sorted_bases[@]}"; do - filename=$(basename "$base") + filename=$(basename "$base") # Get basename if [[ "$filename" == *"_0_499999" ]]; then - # Check if the key for this base path is already set in files_to_keep - # Use parameter expansion ${key+x} for safe check with set -u (Bash 4.0+) - if [[ -z "${files_to_keep[$base]+x}" ]]; then + # Check if the basename key is already set in files_to_keep_basenames + if [[ -z "${files_to_keep_basenames[$filename]+x}" ]]; then # <-- Check using basename echo "Marking first range '$filename' to keep for group '$group_name'." - files_to_keep["$base"]=1 # Mark this base path for keeping + files_to_keep_basenames["$filename"]=1 # <-- Store using basename as key first_range_kept=true fi # Don't break here; let it potentially be kept by Rule 2 as well if it's one of the last two @@ -118,13 +118,12 @@ for group_name in "${group_names[@]}"; do start_index=$((num_files - num_to_keep_last)) # Loop through the indices of the ranges to keep for (( i=start_index; i