- ## 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"
+ ## 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.
+ 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.
+ 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