--partiall-dir not behaving like it ought too

Wayne Davison wayned at samba.org
Tue Sep 7 16:55:00 GMT 2004


On Thu, Sep 02, 2004 at 07:58:33AM +0100, SPJ.Schembri wrote:
> rsync -av --progress --partial-dir=./tmp --bwlimit=100 /tcwork/bigfile.tar root at matthew::root

I finally had some time to work on rsync again (I've been rather
busy lately), so I investigated the partial-dir problem.

The code was not handling the case where the destination file was
missing and the partial file was present (it worked if both were
present).  The weirdness is caused by the fact that (unlike the
--compare-dest option) rsync must not base its decision to send on
the presence of the partial-dir file, but on the state of the
destination file.  Some earlier bug-fixes to make sure that rsync
made the right decision to send created the problem where the
partial-dir file might not get reused.

I've checked in a fix to CVS and attached a patch to this email.
Thanks for the report!

..wayne..
-------------- next part --------------
--- generator.c	5 Aug 2004 18:18:36 -0000	1.110
+++ generator.c	7 Sep 2004 16:46:06 -0000
@@ -252,9 +252,9 @@ static void recv_generator(char *fname, 
 			   int f_out)
 {
 	int fd;
-	STRUCT_STAT st;
+	STRUCT_STAT st, partial_st;
 	int statret, stat_errno;
-	char *fnamecmp;
+	char *fnamecmp, *partialptr = NULL;
 	char fnamecmpbuf[MAXPATHLEN];
 
 	if (list_only)
@@ -448,6 +448,16 @@ static void recv_generator(char *fname, 
 		stat_errno = ENOENT;
 	}
 
+	if (partial_dir) {
+		if ((partialptr = partial_dir_fname(fname))
+		    && link_stat(partialptr, &partial_st, 0) == 0
+		    && S_ISREG(partial_st.st_mode)) {
+			if (statret == -1)
+				goto prepare_to_open;
+		} else
+			partialptr = NULL;
+	}
+
 	if (statret == -1) {
 		if (preserve_hard_links && hard_link_check(file, HL_SKIP))
 			return;
@@ -482,6 +492,7 @@ static void recv_generator(char *fname, 
 		return;
 	}
 
+prepare_to_open:
 	if (dry_run || read_batch) {
 		write_int(f_out,i);
 		return;
@@ -493,14 +504,9 @@ static void recv_generator(char *fname, 
 		return;
 	}
 
-	if (partial_dir) {
-		STRUCT_STAT st2;
-		char *partialptr = partial_dir_fname(fname);
-		if (partialptr && link_stat(partialptr, &st2, 0) == 0
-		    && S_ISREG(st2.st_mode)) {
-			st = st2;
-			fnamecmp = partialptr;
-		}
+	if (partialptr) {
+		st = partial_st;
+		fnamecmp = partialptr;
 	}
 
 	/* open the file */


More information about the rsync mailing list