From 47b7da30034530dbbe30a3e3981381ce9583b08e Mon Sep 17 00:00:00 2001 From: TSC competition notification bot Date: Tue, 20 Feb 2024 08:59:42 +0100 Subject: [PATCH] Use production stage to avoid undetected changes in the files When a generated file does alter but keep the file size the same, the previous script was not able to catch the situation as only the file size was compared. The checksumming was not allowed by the provider and the time-based approach was also not possible due to the recreation of all files by Hugo. The solution is to use a local copy of the upstream files with the same times as the upstream ones. By using rsync's more advanced features, only the changed files are going to be rewritten therein. As a result, the time-based approach now works again. --- update-cron.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/update-cron.sh b/update-cron.sh index 4d17c29..a1e6581 100755 --- a/update-cron.sh +++ b/update-cron.sh @@ -6,6 +6,7 @@ flock 100 src=/srv/data/tsc-cloud/homepage/hugo-page dst=/srv/http/tsc/hugo +prod=/srv/data/tsc-cloud/homepage/production cmd="$SSH_ORIGINAL_COMMAND" # echo "$cmd" @@ -47,7 +48,18 @@ doPublishToStage() { } doPublishToProduction() { - rclone sync --stats 3s -c public/ ionos:/ +# This complicated two step publication is required to speed up the transfer. +# The sftp-based production server does not allow to use checksums. +# Hugo recreates all files with the time stamp at building. +# Thus, all files would be transmitted as the time has changed. +# To overcome this, the intermediate cache should have the same times as the upstream server. + echo "Syncing to intermediate stage" + rsync -rlpcv --delete --delete-delay public/ $prod/ + + echo "Syncing from intermediate stage to production web server" + rclone sync --stats 3s $prod/ ionos:/ + + echo "Cleaning up empty directories" rclone rmdirs ionos:/ }