From ac7d768544df612997ebdef8b40d56ab0d468f25 Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 24 Apr 2021 16:52:19 -0400 Subject: Bug Fixes: Wrong lastrun and fetch lookup Typos in the fetch file variable and not using the last run file variable. --- ssync | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ssync b/ssync index 5aafa75..0bf57a2 100755 --- a/ssync +++ b/ssync @@ -23,15 +23,16 @@ SSYNC_DIR=$HOME/.local/ssync FETCHED_FILE=$SSYNC_DIR/fetched FETCH_FILE=$SSYNC_DIR/fetch LASTRAN_FILE=$SSYNC_DIR/lastran -NEXT_RUN_DATE=$(date -Is) -CURGET_FILE=$SSYNC_DIR/.$RUNID +NEXT_RUN_DATE=$(date -u -Is -d '5 minutes ago') +RUN_DIR=$SSYNC_DIR/.runs/ +CURGET_FILE=$RUN_DIR/$RUNID if [ ! -f $LASTRAN_FILE ]; then mkdir -p $SSYNC_DIR echo $NEXT_RUN_DATE > $LASTRAN_FILE log "No run existed marking next run for files newer than: $NEXT_RUN_DATE" exit 0; fi -PREV_RUN_DATE=$(cat $HOME/.local/ssync/.lastran) +PREV_RUN_DATE=$(cat $LASTRAN_FILE) # main @@ -51,9 +52,10 @@ log "Syncing files since: $PREV_RUN_DATE" log "Fetching files" +mkdir -p $RUN_DIR ssh -i $KEY_FILE $REMOTE "find ${REMOTE_DIR} -newermt ${PREV_RUN_DATE} -exec realpath --relative-to ${REMOTE_DIR} {} \;" >> $CURGET_FILE comm -23 <(sort -u $CURGET_FILE) <(sort -u $FETCHED_FILE) > $FETCH_FILE -COUNT=$(wc -l $FETCHED_FILE | cut -d' ' -f1) +COUNT=$(wc -l $FETCH_FILE | cut -d' ' -f1) if [ $COUNT -gt 0 ]; then # -- cgit v1.2.3-54-g00ecf