--delete and --dirs

Guillaume Etorre guillaume_etorre at realmagic.fr
Thu Sep 29 14:26:38 GMT 2005


Looks like it's working for me. I can't say it doesn't break anything 
else though. I'll do some more testing.

Does this have any chance of making it into 2.6.7?

--
Guillaume

Wayne Davison wrote:

>On Tue, Sep 27, 2005 at 07:10:31PM +0200, Guillaume Etorre wrote:
>  
>
>>Is there any reason for --delete not to delete when used with --dirs?
>>    
>>
>
>It's a historical reason due to the original delete code only knowing
>how to handle a from-the-top recursion pass.  When I improved the delete
>code in 2.6.4 (implementing --delete-during and making it more memory
>efficient), the new algorithm is now capable of handling deletions in
>individual directories, so all it would take to implement this is to
>tweak the options processing to not disable --delete when --dirs is
>enabled, and to properly mark directories whose content was sent as
>opposed to solo directories.  The attached patch does this, and I
>don't think it has any unintended side-effects.  Feel free to give it
>a try.
>
>..wayne..
>  
>
>------------------------------------------------------------------------
>
>--- flist.c	17 Sep 2005 21:49:24 -0000	1.304
>+++ flist.c	28 Sep 2005 17:02:58 -0000
>@@ -650,7 +650,7 @@ static struct file_struct *receive_file_
> 		if (basename_len == 1+1 && *basename == '.') /* +1 for '\0' */
> 			file->dir.depth--;
> 		if (flags & XMIT_TOP_DIR) {
>-			in_del_hier = 1;
>+			in_del_hier = recurse;
> 			del_hier_name_len = file->dir.depth == 0 ? 0 : l1 + l2;
> 			if (relative_paths && del_hier_name_len > 2
> 			    && basename_len == 1+1 && *basename == '.')
>@@ -1228,10 +1228,11 @@ struct file_list *send_file_list(int f, 
> 		if (one_file_system)
> 			filesystem_dev = st.st_dev;
> 
>-		if ((file = send_file_name(f, flist, fname, XMIT_TOP_DIR))) {
>-			if (recurse || (xfer_dirs && is_dot_dir))
>+		if (recurse || (xfer_dirs && is_dot_dir)) {
>+			if ((file = send_file_name(f, flist, fname, XMIT_TOP_DIR)))
> 				send_if_directory(f, flist, file);
>-		}
>+		} else
>+			send_file_name(f, flist, fname, 0);
> 
> 		if (olddir[0]) {
> 			flist_dir = NULL;
>--- options.c	21 Sep 2005 22:39:49 -0000	1.278
>+++ options.c	28 Sep 2005 17:02:59 -0000
>@@ -1022,7 +1022,7 @@ int parse_arguments(int *argc, const cha
> 			"You may not combine multiple --delete-WHEN options.\n");
> 		return 0;
> 	}
>-	if (!recurse) {
>+	if (!recurse && !xfer_dirs) {
> 		delete_before = delete_during = delete_after = 0;
> 		delete_mode = delete_excluded = 0;
> 	} else if (delete_before || delete_during || delete_after)
>  
>
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the rsync mailing list