- Decided to put the new, smaller delete_files() back into
authorWayne Davison <wayned@samba.org>
Fri, 21 Jan 2005 11:00:18 +0000 (11:00 +0000)
committerWayne Davison <wayned@samba.org>
Fri, 21 Jan 2005 11:00:18 +0000 (11:00 +0000)
  receiver.c.
- Got rid of the call of add_cvs_excludes() in the delete_files()
  function because it potentially adds the excludes a second time.
  Instead, make sure that the one code path in main.c that was
  missing the add_cvs_excludes() call now calls it.

delete-during.diff

index c372bcb..c48ead4 100644 (file)
@@ -12,7 +12,7 @@ invoke, either personally or site-wide, without having to recompile rsync).
 Be sure to run "make proto" before "make".
 
 --- orig/flist.c       2005-01-21 00:35:26
-+++ flist.c    2005-01-21 02:08:54
++++ flist.c    2005-01-21 10:16:02
 @@ -35,6 +35,7 @@ extern int am_root;
  extern int am_server;
  extern int am_daemon;
@@ -130,7 +130,7 @@ Be sure to run "make proto" before "make".
  
                if (olddir[0]) {
                        flist_dir = NULL;
-@@ -1634,3 +1660,91 @@ char *f_name(struct file_struct *f)
+@@ -1634,3 +1660,72 @@ char *f_name(struct file_struct *f)
  
        return f_name_to(f, names[n]);
  }
@@ -203,37 +203,17 @@ Be sure to run "make proto" before "make".
 +      }
 +      flist_free(del_flist);
 +}
-+
-+/* This deletes any files on the receiving side that are not present on the
-+ * sending side.  This is used by --delete-before and --delete-after. */
-+void delete_files(struct file_list *flist)
-+{
-+      char fbuf[MAXPATHLEN];
-+      int j;
-+
-+      if (cvs_exclude)
-+              add_cvs_excludes();
-+
-+      for (j = 0; j < flist->count; j++) {
-+              if (!(flist->files[j]->flags & FLAG_DEL_START)
-+                  || !S_ISDIR(flist->files[j]->mode))
-+                      continue;
-+
-+              delete_in_dir(flist, f_name_to(flist->files[j], fbuf), recurse);
-+      }
-+}
 --- orig/generator.c   2005-01-20 23:05:34
-+++ generator.c        2005-01-21 01:59:39
-@@ -34,6 +34,8 @@ extern int preserve_hard_links;
++++ generator.c        2005-01-21 10:21:39
+@@ -34,6 +34,7 @@ extern int preserve_hard_links;
  extern int preserve_perms;
  extern int preserve_uid;
  extern int preserve_gid;
 +extern int delete_during;
-+extern int cvs_exclude;
  extern int update_only;
  extern int opt_ignore_existing;
  extern int inplace;
-@@ -233,7 +235,8 @@ static void generate_and_send_sums(int f
+@@ -233,7 +234,8 @@ static void generate_and_send_sums(int f
   * @note This comment was added later by mbp who was trying to work it
   * out.  It might be wrong.
   */
@@ -243,7 +223,7 @@ Be sure to run "make proto" before "make".
                           int f_out, int f_out_name)
  {
        int fd = -1, f_copy = -1;
-@@ -308,6 +311,11 @@ static void recv_generator(char *fname, 
+@@ -308,6 +310,11 @@ static void recv_generator(char *fname, 
                }
                /* f_out is set to -1 when doing final directory-permission
                 * and modification-time repair. */
@@ -255,17 +235,7 @@ Be sure to run "make proto" before "make".
                if (set_perms(fname, file, statret ? NULL : &st, 0)
                    && verbose && f_out != -1)
                        rprintf(FINFO, "%s/\n", safe_fname(fname));
-@@ -618,6 +626,9 @@ void generate_files(int f_out, struct fi
-                       : "delta transmission enabled\n");
-       }
-+      if (delete_during && cvs_exclude)
-+              add_cvs_excludes();
-+
-       /* we expect to just sit around now, so don't exit on a
-          timeout. If we really get a timeout then the other process should
-          exit */
-@@ -641,7 +652,7 @@ void generate_files(int f_out, struct fi
+@@ -641,7 +648,7 @@ void generate_files(int f_out, struct fi
                }
  
                recv_generator(local_name ? local_name : f_name_to(file, fbuf),
@@ -274,7 +244,7 @@ Be sure to run "make proto" before "make".
        }
  
        phase++;
-@@ -658,7 +669,7 @@ void generate_files(int f_out, struct fi
+@@ -658,7 +665,7 @@ void generate_files(int f_out, struct fi
        while ((i = get_redo_num()) != -1) {
                struct file_struct *file = flist->files[i];
                recv_generator(local_name ? local_name : f_name_to(file, fbuf),
@@ -283,7 +253,7 @@ Be sure to run "make proto" before "make".
        }
  
        phase++;
-@@ -680,7 +691,7 @@ void generate_files(int f_out, struct fi
+@@ -680,7 +687,7 @@ void generate_files(int f_out, struct fi
                if (!file->basename || !S_ISDIR(file->mode))
                        continue;
                recv_generator(local_name ? local_name : f_name(file),
@@ -293,7 +263,7 @@ Be sure to run "make proto" before "make".
  
        if (verbose > 2)
 --- orig/main.c        2005-01-17 23:11:45
-+++ main.c     2005-01-18 21:56:05
++++ main.c     2005-01-21 10:55:05
 @@ -33,6 +33,7 @@ extern int verbose;
  extern int blocking_io;
  extern int cvs_exclude;
@@ -314,6 +284,15 @@ Be sure to run "make proto" before "make".
                        delete_files(flist);
        }
  
+@@ -735,6 +736,8 @@ int client_run(int f_in, int f_out, pid_
+       if (!read_batch)
+               send_exclude_list(f_out);
++      if (cvs_exclude)
++              add_cvs_excludes();
+       if (filesfrom_fd >= 0) {
+               io_set_filesfrom_fds(filesfrom_fd, f_out);
 --- orig/options.c     2005-01-20 23:05:34
 +++ options.c  2005-01-20 23:06:33
 @@ -54,6 +54,8 @@ int dry_run = 0;
@@ -418,7 +397,7 @@ Be sure to run "make proto" before "make".
  
                if (delete_after)
 --- orig/receiver.c    2005-01-21 00:35:26
-+++ receiver.c 2005-01-18 22:47:38
++++ receiver.c 2005-01-21 10:22:37
 @@ -23,7 +23,6 @@
  extern int verbose;
  extern int recurse;
@@ -445,7 +424,7 @@ Be sure to run "make proto" before "make".
  extern int cleanup_got_literal;
  extern int module_id;
  extern int ignore_errors;
-@@ -57,70 +52,6 @@ extern int inplace;
+@@ -57,66 +52,19 @@ extern int inplace;
  extern struct exclude_list_struct server_exclude_list;
  
  
@@ -458,8 +437,10 @@ Be sure to run "make proto" before "make".
 -
 -/* This deletes any files on the receiving side that are not present
 - * on the sending side. */
--void delete_files(struct file_list *flist)
--{
++/* This deletes any files on the receiving side that are not present on the
++ * sending side.  This is used by --delete-before and --delete-after. */
+ void delete_files(struct file_list *flist)
+ {
 -      struct file_list *local_file_list;
 -      int i, j;
 -      char *argv[1], fbuf[MAXPATHLEN];
@@ -472,12 +453,14 @@ Be sure to run "make proto" before "make".
 -              rprintf(FINFO,"IO error encountered - skipping file deletion\n");
 -              return;
 -      }
--
--      for (j = 0; j < flist->count; j++) {
--              if (!(flist->files[j]->flags & FLAG_DEL_START)
--                  || !S_ISDIR(flist->files[j]->mode))
--                      continue;
--
++      char fbuf[MAXPATHLEN];
++      int j;
+       for (j = 0; j < flist->count; j++) {
+               if (!(flist->files[j]->flags & FLAG_DEL_START)
+                   || !S_ISDIR(flist->files[j]->mode))
+                       continue;
 -              argv[0] = f_name_to(flist->files[j], fbuf);
 -
 -              if (!(local_file_list = send_file_list(-1, 1, argv)))
@@ -509,13 +492,10 @@ Be sure to run "make proto" before "make".
 -                      }
 -              }
 -              flist_free(local_file_list);
--      }
--}
--
--
- /*
-  * get_tmpname() - create a tmp filename for a given filename
-  *
++              delete_in_dir(flist, f_name_to(flist->files[j], fbuf), recurse);
+       }
+ }
 --- orig/rsync.yo      2005-01-20 19:47:08
 +++ rsync.yo   2005-01-19 01:05:05
 @@ -341,14 +341,15 @@ verb(