Partial files left on SIGINT

Wayne Davison wayned at samba.org
Thu May 18 18:48:46 GMT 2006


On Thu, May 18, 2006 at 04:43:58PM +0100, Jon Mitchell wrote:
> -rw------- 1 jmitchell users 36700160 2006-05-18 16:36 .big_file.b1eEq1
> 
> This is I believe a partially transferred copy of .big_file.

Yes and no.  You're right that the file should have gotten deleted, just
wrong in the terminology of what you're seeing.  (Aside: this is a temp
file, which rsync should never leave behind; a "partial" file in rsync's
terminology would have been created if this temp file had been renamed
to be "big_file" when the transfer got interrupted.)

This turns out to be a bug in the cleanup code that was introduced in
2.6.7.  The attached patch fixes this.

Thanks for the report!

..wayne..
-------------- next part --------------
--- cleanup.c	9 May 2006 18:31:00 -0000	1.39
+++ cleanup.c	18 May 2006 18:35:30 -0000
@@ -121,7 +121,7 @@ void _exit_cleanup(int code, const char 
 		}
 	}
 
-	if (cleanup_got_literal && cleanup_fname && keep_partial
+	if (cleanup_got_literal && cleanup_new_fname && keep_partial
 	    && handle_partial_dir(cleanup_new_fname, PDIR_CREATE)) {
 		char *fname = cleanup_fname;
 		cleanup_fname = NULL;
@@ -168,7 +168,7 @@ void _exit_cleanup(int code, const char 
 
 void cleanup_disable(void)
 {
-	cleanup_fname = NULL;
+	cleanup_fname = cleanup_new_fname = NULL;
 	cleanup_got_literal = 0;
 }
 
@@ -176,8 +176,8 @@ void cleanup_disable(void)
 void cleanup_set(char *fnametmp, char *fname, struct file_struct *file,
 		 int fd_r, int fd_w)
 {
-	cleanup_fname = fname ? fnametmp : NULL;
-	cleanup_new_fname = fname;
+	cleanup_fname = fnametmp;
+	cleanup_new_fname = fname; /* can be NULL on a partial-dir failure */
 	cleanup_file = file;
 	cleanup_fd_r = fd_r;
 	cleanup_fd_w = fd_w;
--- receiver.c	18 May 2006 17:04:40 -0000	1.178
+++ receiver.c	18 May 2006 18:35:30 -0000
@@ -591,8 +591,7 @@ int recv_files(int f_in, struct file_lis
 				continue;
 			}
 
-			if (keep_partial)
-				cleanup_set(fnametmp, partialptr, file, fd1, fd2);
+			cleanup_set(fnametmp, partialptr, file, fd1, fd2);
 		}
 
 		/* log the transfer */


More information about the rsync mailing list