From: Wayne Davison Date: Wed, 24 Sep 2008 02:27:14 +0000 (-0700) Subject: Fixed skipping of unneeded updates in a batch file when X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/af2dea60336bb6ce4934c21e2274667d293004cc Fixed skipping of unneeded updates in a batch file when incremental recursion is active. Added test. --- diff --git a/generator.c b/generator.c index 85577408..4bc3f67a 100644 --- a/generator.c +++ b/generator.c @@ -2285,6 +2285,9 @@ void generate_files(int f_out, const char *local_name) } } while ((cur_flist = cur_flist->next) != NULL); + if (read_batch) + write_ndx(f_out, NDX_DONE); + if (delete_during) delete_in_dir(NULL, NULL, &dev_zero); phase++; diff --git a/receiver.c b/receiver.c index 3afc40fb..72972b04 100644 --- a/receiver.c +++ b/receiver.c @@ -351,6 +351,8 @@ static void handle_delayed_updates(char *local_name) static int get_next_gen_ndx(int fd, int next_gen_ndx, int desired_ndx) { + static int batch_eof = 0; + while (next_gen_ndx < desired_ndx) { if (next_gen_ndx >= 0) { struct file_struct *file = cur_flist->files[next_gen_ndx]; @@ -359,14 +361,16 @@ static int get_next_gen_ndx(int fd, int next_gen_ndx, int desired_ndx) file->flags & FLAG_FILE_SENT ? " resend of" : "", f_name(file, NULL)); } - next_gen_ndx = read_int(fd); + next_gen_ndx = batch_eof ? -1 : read_int(fd); if (next_gen_ndx == -1) { if (inc_recurse) next_gen_ndx = first_flist->prev->used + first_flist->prev->ndx_start; else next_gen_ndx = cur_flist->used; + batch_eof = 1; } } + return next_gen_ndx; } @@ -520,8 +524,6 @@ int recv_files(int f_in, char *local_name) "(Skipping batched update for \"%s\")\n", fname); discard_receive_data(f_in, F_LENGTH(file)); - if (inc_recurse) - send_msg_int(MSG_NO_SEND, ndx); continue; } next_gen_ndx = -1; diff --git a/testsuite/batch-mode.test b/testsuite/batch-mode.test index 6b32ca54..7f92e482 100644 --- a/testsuite/batch-mode.test +++ b/testsuite/batch-mode.test @@ -41,6 +41,8 @@ runtest "--read-batch from daemon" 'checkit "$RSYNC -av --read-batch=BATCH \"$to rm -rf "$todir" runtest "BATCH.sh use of --read-batch" 'checkit "./BATCH.sh" "$chkdir" "$todir"' +runtest "do-nothing re-run of batch" 'checkit "./BATCH.sh" "$chkdir" "$todir"' + rm -rf "$todir" mkdir "$todir" || test_fail "failed to restore empty destination directory" runtest "daemon recv --write-batch" 'checkit "\"$ignore23\" $RSYNC -av --write-batch=BATCH \"$fromdir/\" rsync://localhost/test-to" "$chkdir" "$todir"'