Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-09-10 09:42:28 +0200
committerErich Eckner <git@eckner.net>2018-09-10 09:42:28 +0200
commit0eae9c3f895ddf187e3807aa76ae3400379a2ad1 (patch)
treef08c3b7ad5038c9d810c26cfba29aa90c93f643a /lib
parent6d10a24d55bfdadcce69f3f0beb4c1a018af8060 (diff)
lib/common-functions: failsafe_rsync() new
Diffstat (limited to 'lib')
-rwxr-xr-xlib/common-functions29
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/common-functions b/lib/common-functions
index 6e0892d..7776725 100755
--- a/lib/common-functions
+++ b/lib/common-functions
@@ -225,12 +225,12 @@ remove_old_package_versions() {
# repo-remove packages
while read -r arch repo pkgname; do
mkdir "${tmp_dir}/transit"
- ${master_mirror_rsync_command} \
+ failsafe_rsync \
"${master_mirror_rsync_directory}/${arch}/${repo}/${repo}.db."* \
"${master_mirror_rsync_directory}/${arch}/${repo}/${repo}.files."* \
"${tmp_dir}/transit/"
repo-remove "${tmp_dir}/transit/${repo}.db.tar.gz" "${pkgname}"
- ${master_mirror_rsync_command} \
+ failsafe_rsync \
"${tmp_dir}/transit/${repo}.db."* \
"${tmp_dir}/transit/${repo}.files."* \
"${master_mirror_rsync_directory}/${arch}/${repo}/"
@@ -709,7 +709,7 @@ trigger_mirror_refreshs() {
tmp_file=$(mktemp "tmp.common-functions.trigger_mirror_refreshs.XXXXXXXXXX" --tmpdir)
date '+%s' > \
"${tmp_file}"
- ${master_mirror_rsync_command} \
+ failsafe_rsync \
"${tmp_file}" \
"${master_mirror_rsync_directory}/lastupdate"
rm "${tmp_file}"
@@ -882,3 +882,26 @@ failsafe_sftp() {
) || \
return $?
}
+
+# failsafe_rsync
+# execute rsync with the given parameters on the master mirror, retrying
+# if unsuccessful
+# caveats:
+# - output might be garbled
+# - error code will be projected into {0,1}
+failsafe_rsync() {
+ local trial_counter
+
+ trial_counter=20
+ if ${master_mirror_rsync_command} "$@"; then
+ return 0
+ fi
+ while [ ${trial_counter} -gt 0 ]; do
+ wait_some_time 30
+ if ${master_mirror_rsync_command} "$@"; then
+ return 0
+ fi
+ trial_counter=$((trial_counter-1))
+ done
+ return 1
+}