Skip to content

Commit

Permalink
Properly handle rsync errors
Browse files Browse the repository at this point in the history
Do not update timed links and packages index when repo_rsync failed.
  • Loading branch information
seblu committed May 14, 2017
1 parent bc98d8d commit 0fad1c7
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,16 @@ repo_rsync() {
msg2 'Rsyncing...'
# rsync from master using last sync
# we must use absolute path with --link-dest to avoid errors
timeout $REPO_RSYNC_TIMEOUT rsync -rltH $LINKDEST \
--filter ". $FILTER_FILE" "$ARCHIVE_RSYNC" "$SNAP/" ||
if ! timeout $REPO_RSYNC_TIMEOUT rsync -rltH $LINKDEST \
--filter ". $FILTER_FILE" "$ARCHIVE_RSYNC" "$SNAP/"; then
error "Unable to rsync: $ARCHIVE_RSYNC."
return 1
fi

# only to have a quick check of sync in listdir
touch "$SNAP"

return 0
}

# output the last repository snapshot
Expand Down Expand Up @@ -220,9 +224,12 @@ iso_rsync() {
[[ -d "$ISO_DIR" ]] || mkdir -p "$ISO_DIR"

# Rsync from master using last sync
timeout $ISO_RSYNC_TIMEOUT rsync -vrltH "$ISO_RSYNC" \
--include='/????.??.??/***' --exclude='*' "$ISO_DIR/" ||
if ! timeout $ISO_RSYNC_TIMEOUT rsync -vrltH "$ISO_RSYNC" \
--include='/????.??.??/***' --exclude='*' "$ISO_DIR/"; then
error "Unable to rsync: $ISO_RSYNC."
return 1
fi
return 0
}

main() {
Expand Down Expand Up @@ -250,11 +257,13 @@ main() {
if (( $ARCHIVE_REPO )); then
REPO_DIR="$ARCHIVE_DIR/repos"

repo_rsync

(( $REPO_DAYLY )) && repo_daily
if repo_rsync; then
# do not update daily links when rsync fail. this could end-up with a
# last pointing to an empty repo.
(( $REPO_DAYLY )) && repo_daily
(( $REPO_PACKAGES )) && repo_packages
fi

(( $REPO_PACKAGES )) && repo_packages
fi

(( $ARCHIVE_ISO )) && iso_rsync
Expand Down

0 comments on commit 0fad1c7

Please sign in to comment.