Added an extra phase to the end of the transfer to handle
[rsync/rsync.git] / generator.c
index 34462c8..9a27c13 100644 (file)
@@ -337,6 +337,8 @@ void itemize(struct file_struct *file, int ndx, int statret, STRUCT_STAT *st,
        if ((iflags & SIGNIFICANT_ITEM_FLAGS || verbose > 1
          || (xname && *xname)) && !read_batch) {
                if (protocol_version >= 29) {
+                       if (iflags & (ITEM_LOCAL_CHANGE|ITEM_TRANSFER))/* XXX */
+                               iflags |= ITEM_DUMMY_BIT; /* XXX Remove soon */
                        if (ndx >= 0)
                                write_int(sock_f_out, ndx);
                        write_shortint(sock_f_out, iflags);
@@ -585,7 +587,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                           enum logcode code, int f_out)
 {
        static int missing_below = -1, excluded_below = -1;
-       static char *fuzzy_dirname = NULL;
+       static char *fuzzy_dirname = "";
        static struct file_list *fuzzy_dirlist = NULL;
        struct file_struct *fuzzy_file = NULL;
        int fd = -1, f_copy = -1;
@@ -603,7 +605,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                if (fuzzy_dirlist) {
                        flist_free(fuzzy_dirlist);
                        fuzzy_dirlist = NULL;
-                       fuzzy_dirname = NULL;
+                       fuzzy_dirname = "";
                }
                if (missing_below >= 0) {
                        dry_run--;
@@ -647,15 +649,13 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
        } else {
                if (fuzzy_basis && S_ISREG(file->mode)) {
                        char *dn = file->dirname ? file->dirname : ".";
-                       /* Yes, identical dirnames are guaranteed to have
-                        * identical pointers at this point. */
-                       if (fuzzy_dirname != dn) {
+                       if (fuzzy_dirname != dn
+                           && strcmp(fuzzy_dirname, dn) != 0) {
                                if (fuzzy_dirlist)
                                        flist_free(fuzzy_dirlist);
-                               fuzzy_dirname = dn;
-                               fuzzy_dirlist = get_dirlist(fuzzy_dirname, -1,
-                                                           1);
+                               fuzzy_dirlist = get_dirlist(dn, -1, 1);
                        }
+                       fuzzy_dirname = dn;
                }
 
                statret = link_stat(fname, &st,
@@ -1241,9 +1241,8 @@ void generate_files(int f_out, struct file_list *flist, char *local_name)
                                continue;
                        if (!need_retouch_dir_times && file->mode & S_IWUSR)
                                continue;
-                       recv_generator(local_name ? local_name : f_name(file),
-                                      file, i, itemizing, maybe_PERMS_REPORT,
-                                      code, -1);
+                       recv_generator(f_name(file), file, i, itemizing,
+                                      maybe_PERMS_REPORT, code, -1);
                        if (allowed_lull && !(j++ % lull_mod))
                                maybe_send_keepalive();
                }
@@ -1257,6 +1256,12 @@ void generate_files(int f_out, struct file_list *flist, char *local_name)
                io_error |= IOERR_DEL_LIMIT;
        }
 
+       if (protocol_version >= 29) {
+               write_int(f_out, -1);
+               /* Read post-delay-phase MSG_DONE and any prior messages. */
+               get_redo_num(itemizing, code);
+       }
+
        if (verbose > 2)
                rprintf(FINFO,"generate_files finished\n");
 }