From 9c2f56ea63b36dd54c7e4df07ade18ae6b111bd2 Mon Sep 17 00:00:00 2001 From: GRMrGecko Date: Tue, 20 Feb 2024 11:09:48 -0600 Subject: [PATCH] Avoid double repo size updating --- mirror-file-generator.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mirror-file-generator.sh b/mirror-file-generator.sh index d21ffde..457bf89 100644 --- a/mirror-file-generator.sh +++ b/mirror-file-generator.sh @@ -256,6 +256,10 @@ if (( ${#selected_mirrors[@]} == 0 )); then done fi +# Keep track of repos which sizes were updated for to +# avoid updating sizes in multi mirror situations. +repo_sizes_updated=() + # Scan each mirror and build files. for ((i=0; i<${#selected_mirrors[@]}; i++)); do mirror=${selected_mirrors[i]} @@ -450,7 +454,12 @@ for ((i=0; i<${#selected_mirrors[@]}; i++)); do unknown_path="$dir_sizes_unknown_path/$mirror/$dir_name" # If we should update the directory usage sizes, do so. - if ((update_unknown_dir_size)) && ((${disable_size_calc:-0} == 0)); then + # shellcheck disable=SC2076 + if ((update_unknown_dir_size)) && ((${disable_size_calc:-0} == 0)) \ + && [[ ! " ${repo_sizes_updated[*]} " =~ " ${real_dir} " ]]; then + # Add to list of repos with updated sizes. + repo_sizes_updated+=("$real_dir") + log "Generating sum file for $dir_name" # If the mirror dir under the unknown repo path doesn't exist, create it. if [[ ! -e "$dir_sizes_unknown_path/$mirror" ]]; then