Properly handle a failure to create a partial directory, which is
authorWayne Davison <wayned@samba.org>
Sat, 2 Aug 2008 00:53:43 +0000 (17:53 -0700)
committerWayne Davison <wayned@samba.org>
Sat, 2 Aug 2008 01:00:09 +0000 (18:00 -0700)
especially important for --delay-updates, particularly when
--remove-source-files was also specified.

NEWS
receiver.c

diff --git a/NEWS b/NEWS
index 29f1ef2ea960d22a374395896fa87772be93e721..12e45e86e0c919b012fd769349d0f26c9efce51f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,11 @@ Changes since 3.0.3:
     - Fixed the hard-linking of files from a device that has a device number
       of 0 (which seems to be a common device number on NetBSD).
 
+    - Fixed the handling of a --partial-dir that cannot be created.  This
+      particularly impacts the --delay-updates option (since the files cannot
+      be delayed without a partial-dir), and was potentially destructive if
+      the --remove-source-files was also specified.
+
     - Fixed a couple issues in the --fake-super handling of xattrs when the
       destination files have root-level attributes (e.g. selinux values) that
       a non-root copy can't affect.
index ce6b739487fe3136430e53fd02ab6bf20ac79a3e..1ff029d4fb216f804e50bd2dab9aa99143334be9 100644 (file)
@@ -698,23 +698,30 @@ int recv_files(int f_in, char *local_name)
                                do_unlink(partialptr);
                                handle_partial_dir(partialptr, PDIR_DELETE);
                        }
-               } else if (keep_partial && partialptr
-                   && handle_partial_dir(partialptr, PDIR_CREATE)) {
-                       if (!finish_transfer(partialptr, fnametmp, fnamecmp, NULL,
-                                            file, recv_ok, !partial_dir))
+               } else if (keep_partial && partialptr) {
+                       if (!handle_partial_dir(partialptr, PDIR_CREATE)) {
+                               rprintf(FERROR,
+                                   "Unable to create partial-dir for %s -- discarding %s.\n",
+                                   local_name ? local_name : f_name(file, NULL),
+                                   recv_ok ? "completed file" : "partial file");
+                               do_unlink(fnametmp);
+                               recv_ok = -1;
+                       } else if (!finish_transfer(partialptr, fnametmp, fnamecmp, NULL,
+                                                   file, recv_ok, !partial_dir))
                                recv_ok = -1;
                        else if (delay_updates && recv_ok) {
                                bitbag_set_bit(delayed_bits, ndx);
                                recv_ok = 2;
-                       }
-               } else {
-                       partialptr = NULL;
+                       } else
+                               partialptr = NULL;
+               } else
                        do_unlink(fnametmp);
-               }
 
                cleanup_disable();
 
                switch (recv_ok) {
+               case 2:
+                       break;
                case 1:
                        if (remove_source_files || inc_recurse
                         || (preserve_hard_links && F_IS_HLINKED(file)))