- Handle the receive-failed case properly.
[rsync/rsync-patches.git] / partial-dir.diff
index 407d2e4..9e9beaf 100644 (file)
@@ -112,7 +112,7 @@ You must run "make proto" after applying this patch.
        }
  
 -      if (keep_partial)
-+      if (partial_dir) {
++      if (partial_dir && am_sender) {
 +              args[ac++] = "--partial-dir";
 +              args[ac++] = partial_dir;
 +      } else if (keep_partial)
@@ -180,24 +180,55 @@ You must run "make proto" after applying this patch.
                }
  
                if (!am_server && verbose)
-@@ -544,11 +557,16 @@ int recv_files(int f_in, struct file_lis
+@@ -544,10 +557,20 @@ int recv_files(int f_in, struct file_lis
                        exit_cleanup(RERR_FILEIO);
                }
  
 -              if (recv_ok || keep_partial || inplace)
-+              if (recv_ok || (keep_partial && partialptr) || inplace)
++              if (recv_ok || inplace)
                        finish_transfer(fname, fnametmp, file, recv_ok);
-               else
+-              else
++              else if (keep_partial && partialptr
++                  && (!partial_dir || handle_partial_dir(partialptr, 1)))
++                      finish_transfer(partialptr, fnametmp, file, 0);
++              else {
++                      partialptr = NULL;
                        do_unlink(fnametmp);
-+              if (partialptr != fname && fnamecmp == partialptr) {
++              }
++
++              if (partialptr != fname && fnamecmp == partialptr && recv_ok) {
 +                      do_unlink(partialptr);
 +                      handle_partial_dir(partialptr, 0);
 +              }
-+
                cleanup_disable();
  
-               if (!recv_ok) {
+@@ -555,9 +578,13 @@ int recv_files(int f_in, struct file_lis
+                       int msgtype = csum_length == SUM_LENGTH || read_batch ?
+                               FERROR : FINFO;
+                       if (msgtype == FERROR || verbose) {
+-                              char *errstr, *redostr;
+-                              char *keptstr = keep_partial || inplace ?
+-                                      "retain" : "discard";
++                              char *errstr, *redostr, *keptstr;
++                              if (!(keep_partial && partialptr) && !inplace)
++                                      keptstr = "discarded";
++                              else if (partial_dir)
++                                      keptstr = "put into partial-dir";
++                              else
++                                      keptstr = "retained";
+                               if (msgtype == FERROR) {
+                                       errstr = "ERROR";
+                                       redostr = "";
+@@ -566,7 +593,7 @@ int recv_files(int f_in, struct file_lis
+                                       redostr = " (will try again)";
+                               }
+                               rprintf(msgtype,
+-                                      "%s: %s failed verification -- update %sed%s.\n",
++                                      "%s: %s failed verification -- update %s%s.\n",
+                                       errstr, fname, keptstr, redostr);
+                       }
+                       if (csum_length != SUM_LENGTH) {
 --- orig/rsync.yo      2004-07-24 16:52:10
 +++ rsync.yo   2004-07-23 19:36:41
 @@ -317,6 +317,7 @@ verb(
@@ -208,7 +239,7 @@ You must run "make proto" after applying this patch.
       --force                 force deletion of dirs even if not empty
       --numeric-ids           don't map uid/gid values by user/group name
       --timeout=TIME          set I/O timeout in seconds
-@@ -865,6 +866,21 @@ it is more desirable to keep partially t
+@@ -865,6 +866,25 @@ it is more desirable to keep partially t
  --partial option tells rsync to keep the partial file which should
  make a subsequent transfer of the rest of the file much faster.
  
@@ -223,9 +254,13 @@ You must run "make proto" after applying this patch.
 +in the tree (rsync will also try to remove the DIR if a partial file
 +was found and the DIR was specified as a relative path).
 +
-+If you want to delete files on the destination, be sure to use
-+--delete-after instead of --delete or the partial file may be deleted
-+before it can be used.
++If you want to delete files on the destination and your partial-dir is
++inside the destination hierarchy, you should use --delete-after or add an
++--exclude to prevent the partial file from being deleted before it can be
++used.
++
++IMPORTANT: do NOT use a directory that is writable by anyone for the
++--partial-dir (such as /tmp) -- it is insecure!
 +
  dit(bf(--progress)) This option tells rsync to print information
  showing the progress of the transfer. This gives a bored user