- ## Get a matching map of the files received.
- mkdir -m750 -p $STOREDIR/tmp
- localmap=$STOREDIR/tmp/fshash.$host.$fs.$date
- $verbose -n " local fshash..."
- run "local fshash $host:$fs" local_fshash || return $?
- $verbose " done"
-
- ## Compare the two maps.
- run "compare fshash maps for $host:$fs" \
- diff -u new.fshash $localmap || return $?
- rm -f $localmap
+ ## If we failed to copy, then give up.
+ case $rc_rsync:$rc_fshash in
+ 0:0) ;;
+ 0:*) return $rc_fshash ;;
+ *) return $rc_rsync ;;
+ esac
+
+ ## Get a matching map of the files received.
+ maybe mkdir -m750 -p $STOREDIR/tmp/
+ localmap=$STOREDIR/tmp/fshash.$host.$fs.$date
+ case $dryrun in
+ t) $verbose " local fshash" ;;
+ nil) $verbose -n " local fshash..." ;;
+ esac
+ run "local fshash $host:$fs" local_fshash || return $?
+ case $dryrun in nil) $verbose " done" ;; esac
+
+ ## Compare the two maps.
+ set +e
+ run "compare fshash maps for $host:$fs" diff -u new.fshash $localmap
+ rc_diff=$?
+ set -e
+ case $rc_diff in
+ 0)
+ break
+ ;;
+ 1)
+ if [ $attempt -ge $retry ]; then return $rc; fi
+ $verbose " fshash mismatch; retrying"
+ attempt=$(( $attempt + 1 ))
+ ;;
+ *)
+ return $rc_diff
+ ;;
+ esac
+ done
+
+ ## Glorious success.
+ maybe rm -f $localmap