From 7a87be349fbec31dffa8a27bba4c7ea95a047973 Mon Sep 17 00:00:00 2001 From: GRMrGecko Date: Tue, 2 Jan 2024 08:35:01 -0600 Subject: [PATCH] Fix dusum math to save file after sum is complete. --- mirror-sync.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mirror-sync.sh b/mirror-sync.sh index f1be810..35455c0 100644 --- a/mirror-sync.sh +++ b/mirror-sync.sh @@ -5,7 +5,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/mirror/. # Variables for trace generation. PROGRAM="mirror-sync" -VERSION="20231229" +VERSION="20240102" TRACEHOST=$(hostname -f) mirror_hostname=$(hostname -f) DATE_STARTED=$(LC_ALL=POSIX LANG=POSIX date -u -R) @@ -341,7 +341,8 @@ post_successful_sync() { # Update repo directory sum. if [[ $dusum ]]; then - { + # Get a sum, store to variable first to avoid having an empty file when another cron finishes. + SUM=$({ # If modules are defined, sum each module directory. if [[ $modules ]]; then for module in $modules; do @@ -351,7 +352,10 @@ post_successful_sync() { # Standard repo sum. du -s "$repo" fi - } 2>/dev/null > "$dusum" + } 2>/dev/null) + + # Save sum to file. + echo "$SUM" > "$dusum" rebuild_dusum_totals fi