This patch adds the --detect-renamed option which makes rsync notice filesthat either (1) match in size & modify-time (plus the basename, if possible)or (2) match in size & checksum (when --checksum was also specified) and useeach match as an alternate basis file to speed up the transfer.The algorithm attempts to scan the receiving-side's files in an efficientmanner.If --delete[-before] is enabled, we'll take advantage of thepre-transfer delete pass to prepare any alternate-basis-file matches wemight find.If --delete-before is not enabled, rsync does the rename scanduring the regular file-sending scan (scanning each directory right beforethe generator starts updating files from that dir).In this latter mode,rsync might delay the updating of a file (if no alternate-basis match wasyet found) until the full scan of the receiving side is complete, at whichpoint any delayed files are processed.I chose to hard-link the alternate-basis files into a ".~tmp~" subdir thattakes advantage of rsync's pre-existing partial-dir logic.This uses lessmemory than trying to keep track of the matches internally, and also allowsany deletions or file-updates to occur normally without interfering withthese alternate-basis discoveries.To use this patch, run these commands for a successful build:patch -p1 <patches/detect-renamed.diff./configure(optional if already run)makeTODO:We need to never return a match from fattr_find() that has a basisfile.This will ensure that we don't try to give a renamed file toa file that can't use it, while missing out on giving it to a filethat could use it.based-on: 40afd365cc8ca968fd16e161d24df5b8a8a520cc--- a/compat.c+++ b/compat.c@@ -41,6 +41,7 @@ extern int read_batch;extern int delay_updates;extern int checksum_seed;extern int basis_dir_cnt;+extern int detect_renamed;extern int prune_empty_dirs;extern int protocol_version;extern int protect_args;@@ -124,6 +125,7 @@ void set_allow_inc_recurse(void)allow_inc_recurse = 0;else if (!am_sender&& (delete_before || delete_after+|| detect_renamed|| delay_updates || prune_empty_dirs))allow_inc_recurse = 0;else if (am_server && !local_server--- a/flist.c+++ b/flist.c@@ -61,6 +61,7 @@ extern int non_perishable_cnt;extern int prune_empty_dirs;extern int copy_links;extern int copy_unsafe_links;
+extern int detect_renamed;extern int protocol_version;extern int sanitize_paths;extern int munge_symlinks;@@ -121,6 +122,8 @@ static int64 tmp_dev = -1, tmp_ino;#endifstatic char tmp_sum[MAX_DIGEST_LEN];+struct file_list the_fattr_list;+static char empty_sum[MAX_DIGEST_LEN];static int flist_count_offset; /* for --delete --progress */static int dir_count = 0;@@ -288,6 +291,45 @@ static int is_excluded(const char *fnamereturn 0;}+static int fattr_compare(struct file_struct **file1, struct file_struct **file2)+{+struct file_struct *f1 = *file1;+struct file_struct *f2 = *file2;+int64 len1 = F_LENGTH(f1), len2 = F_LENGTH(f2);+int diff;++if (!f1->basename || !S_ISREG(f1->mode) || !len1) {+if (!f2->basename || !S_ISREG(f2->mode) || !len2)+return 0;+return 1;+}+if (!f2->basename || !S_ISREG(f2->mode) || !len2)+return -1;++/* Don't use diff for values that are longer than an int. */+if (len1 != len2)+return len1 < len2 ? -1 : 1;++if (always_checksum) {+
Upload your study docs or become a
Course Hero member to access this document
Upload your study docs or become a
Course Hero member to access this document
End of preview. Want to read all 14 pages?
Upload your study docs or become a
Course Hero member to access this document
Term
Spring
Professor
Bishop
Tags
Computer file, Enumerated type, Rprintf, dirlist