From 6755a7d7426dcc9b887f80f066021dbacffc7b10 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sun, 8 Jul 2007 06:25:47 +0000 Subject: [PATCH] If we get an ndx that is 1 entry prior to an incremental flist's start, it refers to the file list's parent dir. --- receiver.c | 7 +++++-- rsync.c | 11 +++++------ sender.c | 7 +++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/receiver.c b/receiver.c index 4b9f60ec..a1486b1f 100644 --- a/receiver.c +++ b/receiver.c @@ -53,7 +53,7 @@ extern struct stats stats; extern char *tmpdir; extern char *partial_dir; extern char *basis_dir[]; -extern struct file_list *cur_flist, *first_flist; +extern struct file_list *cur_flist, *first_flist, *dir_flist; extern struct filter_list_struct server_filter_list; static struct bitbag *delayed_bits = NULL; @@ -392,7 +392,10 @@ int recv_files(int f_in, char *local_name) continue; } - file = cur_flist->files[ndx - cur_flist->ndx_start]; + if (ndx - cur_flist->ndx_start >= 0) + file = cur_flist->files[ndx - cur_flist->ndx_start]; + else + file = dir_flist->files[cur_flist->parent_ndx]; fname = local_name ? local_name : f_name(file, fbuf); if (verbose > 2) diff --git a/rsync.c b/rsync.c index fbe18c7c..1ae33684 100644 --- a/rsync.c +++ b/rsync.c @@ -198,9 +198,8 @@ int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr, invalid_ndx: rprintf(FERROR, "Invalid file index: %d (%d - %d) with iflags %x [%s]\n", - ndx, first_flist->ndx_start + first_flist->ndx_start, - first_flist->prev->ndx_start + first_flist->ndx_start - + first_flist->prev->used - 1, iflags, who_am_i()); + ndx, first_flist->ndx_start - 1, first_flist->prev->ndx_end, + iflags, who_am_i()); exit_cleanup(RERR_PROTOCOL); } cur_flist = flist; @@ -220,7 +219,7 @@ int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr, if (iflags & ITEM_TRANSFER) { int i = ndx - cur_flist->ndx_start; - if (!S_ISREG(cur_flist->files[i]->mode)) { + if (i < 0 || !S_ISREG(cur_flist->files[i]->mode)) { rprintf(FERROR, "received request to transfer non-regular file: %d [%s]\n", ndx, who_am_i()); @@ -495,12 +494,12 @@ struct file_list *flist_for_ndx(int ndx) if (!flist && !(flist = first_flist)) return NULL; - while (ndx < flist->ndx_start) { + while (ndx < flist->ndx_start-1) { if (flist == first_flist) return NULL; flist = flist->prev; } - while (ndx >= flist->ndx_start + flist->used) { + while (ndx > flist->ndx_end) { if (!(flist = flist->next)) return NULL; } diff --git a/sender.c b/sender.c index 13ae8e4d..397e1c8a 100644 --- a/sender.c +++ b/sender.c @@ -43,7 +43,7 @@ extern int inplace; extern int batch_fd; extern int write_batch; extern struct stats stats; -extern struct file_list *cur_flist, *first_flist; +extern struct file_list *cur_flist, *first_flist, *dir_flist; /** * @file @@ -210,7 +210,10 @@ void send_files(int f_in, int f_out) if (inc_recurse) send_extra_file_list(f_out, FILECNT_LOOKAHEAD); - file = cur_flist->files[ndx - cur_flist->ndx_start]; + if (ndx - cur_flist->ndx_start >= 0) + file = cur_flist->files[ndx - cur_flist->ndx_start]; + else + file = dir_flist->files[cur_flist->parent_ndx]; if (F_PATHNAME(file)) { path = F_PATHNAME(file); slash = "/"; -- 2.34.1