If there is no lchown(), don't try to set the user & group of a symlink.
[rsync/rsync.git] / cleanup.c
index 0316bf9..551e438 100644 (file)
--- a/cleanup.c
+++ b/cleanup.c
@@ -111,13 +111,16 @@ void _exit_cleanup(int code, const char *file, int line)
                }
        }
 
-       if (cleanup_got_literal && cleanup_fname && keep_partial) {
+       if (cleanup_got_literal && cleanup_fname && keep_partial
+           && handle_partial_dir(cleanup_new_fname, PDIR_CREATE)) {
                char *fname = cleanup_fname;
                cleanup_fname = NULL;
                if (cleanup_fd_r != -1)
                        close(cleanup_fd_r);
-               if (cleanup_fd_w != -1)
+               if (cleanup_fd_w != -1) {
+                       flush_write_file(cleanup_fd_w);
                        close(cleanup_fd_w);
+               }
                finish_transfer(cleanup_new_fname, fname, cleanup_file, 0);
        }
        io_flush(FULL_FLUSH);