summaryrefslogtreecommitdiff
path: root/bin/ftpsync
diff options
context:
space:
mode:
authorRaphael Geissert <atomo64@gmail.com>2012-04-26 23:38:17 -0500
committerRaphael Geissert <atomo64@gmail.com>2012-04-26 23:38:17 -0500
commit78ac9758104d9f23e3d8c346bae865902e7f36dd (patch)
treee72a6019f4950a264cec86affb21aea907713262 /bin/ftpsync
parent9d7921a36eabd23d2fd9e842fae01bfe01e8a69c (diff)
Only perform the second stage if upstream is not updating
Instead of not updating the trace file, skip the second stage so that the mirror is kept in a consistent state.
Diffstat (limited to 'bin/ftpsync')
-rwxr-xr-xbin/ftpsync54
1 files changed, 30 insertions, 24 deletions
diff --git a/bin/ftpsync b/bin/ftpsync
index 9cfe35e..646e9d8 100755
--- a/bin/ftpsync
+++ b/bin/ftpsync
@@ -487,17 +487,37 @@ while [ -e "${UPDATEREQUIRED}" ]; do
# if we want stage2 *or* all
if [ "xtruex" = "x${SYNCSTAGE2}x" ] || [ "xtruex" = "x${SYNCALL}x" ]; then
- log "Running stage2: ${RSYNC} ${RSYNC_OPTIONS} ${RSYNC_OPTIONS2} ${EXCLUDE} ${SOURCE_EXCLUDE} ${RSYNCPTH}::${RSYNC_PATH} ${TO}"
+ upstream_uip=false
+ for aupfile in "${TO}/Archive-Update-in-Progress-"*; do
+ case "$aupfile" in
+ "${TO}/Archive-Update-in-Progress-*")
+ :
+ ;;
+ "${LOCK}")
+ :
+ ;;
+ *)
+ upstream_uip=true
+ ;;
+ esac
+ done
- set +e
- # We are lucky, it worked. Now do step 2 and sync again, this time including
- # the packages/releases files
- ${RSYNC} ${RSYNC_OPTIONS} ${RSYNC_OPTIONS2} ${EXCLUDE} ${SOURCE_EXCLUDE} \
- ${RSYNCPTH}::${RSYNC_PATH} "${TO}" >>"${LOGDIR}/rsync-${NAME}.log" 2>>"${LOGDIR}/rsync-${NAME}.error"
- result=$?
- set -e
+ if $upstream_uip; then
+ log "Upstream archive update in progress, skipping stage2 (ignore rsync error below)"
+ result=1
+ else
+ log "Running stage2: ${RSYNC} ${RSYNC_OPTIONS} ${RSYNC_OPTIONS2} ${EXCLUDE} ${SOURCE_EXCLUDE} ${RSYNCPTH}::${RSYNC_PATH} ${TO}"
+
+ set +e
+ # We are lucky, it worked. Now do step 2 and sync again, this time including
+ # the packages/releases files
+ ${RSYNC} ${RSYNC_OPTIONS} ${RSYNC_OPTIONS2} ${EXCLUDE} ${SOURCE_EXCLUDE} \
+ ${RSYNCPTH}::${RSYNC_PATH} "${TO}" >>"${LOGDIR}/rsync-${NAME}.log" 2>>"${LOGDIR}/rsync-${NAME}.error"
+ result=$?
+ set -e
- log "Back from rsync with returncode ${result}"
+ log "Back from rsync with returncode ${result}"
+ fi
else
# Fake a good resultcode
result=0
@@ -523,21 +543,7 @@ done
# We only update our tracefile when we had a stage2 or an all sync.
# Otherwise we would update it after stage1 already, which is wrong.
if [ "xtruex" = "x${SYNCSTAGE2}x" ] || [ "xtruex" = "x${SYNCALL}x" ]; then
- should_update=true
- for aupfile in "${TO}/Archive-Update-in-Progress-"*; do
- case "$aupfile" in
- "${TO}/Archive-Update-in-Progress-*")
- :
- ;;
- "${LOCK}")
- :
- ;;
- *)
- should_update=false
- ;;
- esac
- done
- if $should_update && [ -d "$(dirname "${TO}/${TRACE}")" ]; then
+ if [ -d "$(dirname "${TO}/${TRACE}")" ]; then
LC_ALL=POSIX LANG=POSIX date -u > "${TO}/${TRACE}"
echo "Used ftpsync version: ${VERSION}" >> "${TO}/${TRACE}"
echo "Running on host: $(hostname -f)" >> "${TO}/${TRACE}"