Updated to apply to the latest generator.c code and to have a
authorWayne Davison <wayned@samba.org>
Wed, 2 Mar 2005 10:14:28 +0000 (10:14 +0000)
committerWayne Davison <wayned@samba.org>
Wed, 2 Mar 2005 10:14:28 +0000 (10:14 +0000)
little better error handling.

copy-dest.diff

index 5f2dc13..6a65492 100644 (file)
@@ -2,8 +2,8 @@ This adds the option --copy-dest, which works just like --link-dest
 except that identical files are copied into the destination instead
 of hard-linked.
 
---- orig/generator.c   2005-03-01 19:42:49
-+++ generator.c        2005-03-01 19:43:39
+--- orig/generator.c   2005-03-02 09:51:54
++++ generator.c        2005-03-02 10:05:20
 @@ -65,6 +65,7 @@ extern int always_checksum;
  extern char *partial_dir;
  extern char *basis_dir[];
@@ -12,28 +12,29 @@ of hard-linked.
  extern int link_dest;
  extern int whole_file;
  extern int local_server;
-@@ -831,6 +832,8 @@ static void recv_generator(char *fname, 
-                               case 1:
-                                       if (!unchanged_file(fnamecmpbuf, file, &st))
-                                               continue;
-+                                      if (copy_dest)
-+                                              break;
-                                       fallback_match = i;
-                                       match_level = 2;
-                                       /* FALL THROUGH */
-@@ -848,8 +851,19 @@ static void recv_generator(char *fname, 
-                               pathjoin(fnamecmpbuf, sizeof fnamecmpbuf,
-                                        basis_dir[i], fname);
+@@ -833,6 +834,8 @@ static void recv_generator(char *fname, 
+                                       continue;
+                               best_match = i;
+                               match_level = 2;
++                              if (copy_dest)
++                                      break;
+                               /* FALL THROUGH */
+                       case 2:
+                               if (!unchanged_attrs(file, &st))
+@@ -854,8 +857,20 @@ static void recv_generator(char *fname, 
+                                       statret = -1;
+                               }
                        }
-+                      if ((copy_dest && match_level == 3 && !dry_run)
-+#ifdef HAVE_LINK
-+                          || (link_dest && match_level == 2 && !dry_run)
-+#endif
-+                          ) {
++                      if (match_level == 2 && !dry_run) {
 +                              /* Copy the file locally. */
 +                              if (copy_file(fnamecmpbuf, fname, file->mode) < 0) {
-+                                      fnamecmp = fnamecmpbuf;
-+                                      fnamecmp_type = i;
++                                      if (verbose) {
++                                              rsyserr(FINFO, errno,
++                                                      "copy_file %s => %s",
++                                                      full_fname(fnamecmpbuf),
++                                                      safe_fname(fname));
++                                      }
++                                      statret = -1;
 +                              } else
 +                                      set_perms(fname, file, NULL, 0);
  #ifdef HAVE_LINK
@@ -42,19 +43,19 @@ of hard-linked.
                                if (do_link(fnamecmpbuf, fname) < 0) {
                                        if (verbose) {
                                                rsyserr(FINFO, errno,
-@@ -860,9 +874,8 @@ static void recv_generator(char *fname, 
+@@ -866,9 +881,8 @@ static void recv_generator(char *fname, 
                                        fnamecmp = fnamecmpbuf;
                                        fnamecmp_type = i;
                                }
 -                      } else
  #endif
--                      {
-+                      } else {
+-                      if (statret == 0) {
++                      } else if (statret == 0) {
                                fnamecmp = fnamecmpbuf;
                                fnamecmp_type = i;
                        }
---- orig/options.c     2005-03-01 05:49:24
-+++ options.c  2005-02-23 02:05:34
+--- orig/options.c     2005-03-02 09:17:42
++++ options.c  2005-03-02 10:05:21
 @@ -143,6 +143,7 @@ char *backup_dir = NULL;
  char backup_dir_buf[MAXPATHLEN];
  int rsync_port = 0;
@@ -112,7 +113,7 @@ of hard-linked.
                return 0;
        }
  
---- orig/rsync.yo      2005-03-01 19:42:49
+--- orig/rsync.yo      2005-03-02 08:52:45
 +++ rsync.yo   2005-02-23 02:05:34
 @@ -353,6 +353,7 @@ to the detailed description below for a 
   -T, --temp-dir=DIR          create temporary files in directory DIR
@@ -133,7 +134,7 @@ of hard-linked.
  
  WARNING: The file's data will be in an inconsistent state during the
  transfer (and possibly afterward if the transfer gets interrupted), so you
-@@ -949,9 +950,19 @@ finds an existing file.  That first disc
+@@ -957,9 +958,19 @@ finds an existing file.  That first disc
  and also determines if the transfer needs to happen.
  
  If em(DIR) is a relative path, it is relative to the destination directory.
@@ -155,7 +156,7 @@ of hard-linked.
  unchanged files are hard linked from em(DIR) to the destination directory.
  The files must be identical in all preserved attributes (e.g. permissions,
  possibly ownership) in order for the files to be linked together.
-@@ -965,7 +976,7 @@ the list in the order specified), and if
+@@ -973,7 +984,7 @@ the list in the order specified), and if
  of the em(DIR)s will be selected to try to speed up the transfer.
  
  If em(DIR) is a relative path, it is relative to the destination directory.