If we get an ndx that is 1 entry prior to an incremental flist's
authorWayne Davison <wayned@samba.org>
Sun, 8 Jul 2007 06:25:47 +0000 (06:25 +0000)
committerWayne Davison <wayned@samba.org>
Sun, 8 Jul 2007 06:25:47 +0000 (06:25 +0000)
start, it refers to the file list's parent dir.

receiver.c
rsync.c
sender.c

index 4b9f60ec19e8e00fecab84631a5ddd28255562a3..a1486b1fcdaf985d420b62e3ab7161dc7c64aca3 100644 (file)
@@ -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 fbe18c7c30face7a307e64183de4d16be65fc174..1ae33684358cf6c40350fc668fe610341c8985b4 100644 (file)
--- 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;
        }
index 13ae8e4d41f221550471c6f7dfa4d64850f0226b..397e1c8a19ad5c1c91d17f1b2696f757e2f9bfa9 100644 (file)
--- 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 = "/";