The finish_transfer() call takes an arg that specifies if we should set the
[rsync/rsync.git] / receiver.c
index 108c856..acc5da8 100644 (file)
@@ -45,6 +45,7 @@ extern int cleanup_got_literal;
 extern int module_id;
 extern int ignore_errors;
 extern int orig_umask;
+extern int keep_partial;
 
 static void delete_one(char *fn, int is_dir)
 {
@@ -458,12 +459,19 @@ int recv_files(int f_in,struct file_list *flist,char *local_name)
                if (fd1 != -1) {
                        close(fd1);
                }
-               close(fd2);
+               if (close(fd2) < 0) {
+                       rprintf(FERROR, "close failed on %s: %s\n",
+                               full_fname(fnametmp), strerror(errno));
+                       exit_cleanup(RERR_FILEIO);
+               }
 
                if (verbose > 2)
                        rprintf(FINFO,"renaming %s to %s\n",fnametmp,fname);
 
-               finish_transfer(fname, fnametmp, file);
+               if (recv_ok || keep_partial)
+                       finish_transfer(fname, fnametmp, file, recv_ok);
+               else
+                       do_unlink(fnametmp);
 
                cleanup_disable();