patch to add --ignore-existing (was: transferring files...)
Vipul Ved Prakash
mail at vipul.net
Sun Oct 14 01:15:59 EST 2001
Hi,
I couldn't figure out how to get rsync 2.4.6 to do this, so I added a
--ignore-existing option that ignores existing files on the destination
system (patch attached with this mail). It would be helpful to know if
there's a canonical way of doing this (ie. without having to patch rsync).
best,
vipul.
--
Vipul Ved Prakash | "I almost died, but I made it, so I'm not so
Software Design Artist | serious about formal-wear anymore."
http://vipul.net/ | -- Gene Boggs
-------------- next part --------------
Only in rsync-2.4.6-hacked/: Makefile
Only in rsync-2.4.6-hacked/: config.cache
Only in rsync-2.4.6-hacked/: config.h
Only in rsync-2.4.6-hacked/: config.log
Only in rsync-2.4.6-hacked/: config.status
diff -u rsync-2.4.6/generator.c rsync-2.4.6-hacked/generator.c
--- rsync-2.4.6/generator.c Tue Sep 5 19:46:43 2000
+++ rsync-2.4.6-hacked/generator.c Sat Oct 13 07:53:10 2001
@@ -27,6 +27,7 @@
extern int preserve_devices;
extern int preserve_hard_links;
extern int update_only;
+extern int ignore_existing;
extern int whole_file;
extern int block_size;
extern int csum_length;
@@ -343,6 +344,12 @@
if (!dry_run) send_sums(NULL,f_out);
return;
}
+
+ if (ignore_existing && fnamecmp == fname) {
+ if (verbose > 1)
+ rprintf(FINFO,"%s exists\n",fname);
+ return;
+ }
if (update_only && cmp_modtime(st.st_mtime,file->modtime)>0 && fnamecmp == fname) {
if (verbose > 1)
Common subdirectories: rsync-2.4.6/lib and rsync-2.4.6-hacked/lib
diff -u rsync-2.4.6/options.c rsync-2.4.6-hacked/options.c
--- rsync-2.4.6/options.c Tue Sep 5 19:46:43 2000
+++ rsync-2.4.6-hacked/options.c Sat Oct 13 08:06:07 2001
@@ -65,6 +65,7 @@
int bwlimit=0;
int delete_after=0;
int only_existing=0;
+int ignore_existing=0;
int max_delete=0;
int ignore_errors=0;
#ifdef _WIN32
@@ -141,6 +142,7 @@
rprintf(F," --rsync-path=PATH specify path to rsync on the remote machine\n");
rprintf(F," -C, --cvs-exclude auto ignore files in the same way CVS does\n");
rprintf(F," --existing only update files that already exist\n");
+ rprintf(F," --ignore-existing ignore files that already exist on the receiving side\n");
rprintf(F," --delete delete files that don't exist on the sending side\n");
rprintf(F," --delete-excluded also delete excluded files on the receiving side\n");
rprintf(F," --delete-after delete after transferring, not before\n");
@@ -188,7 +190,7 @@
OPT_LOG_FORMAT, OPT_PASSWORD_FILE, OPT_SIZE_ONLY, OPT_ADDRESS,
OPT_DELETE_AFTER, OPT_EXISTING, OPT_MAX_DELETE, OPT_BACKUP_DIR,
OPT_IGNORE_ERRORS, OPT_BWLIMIT, OPT_BLOCKING_IO,
- OPT_MODIFY_WINDOW};
+ OPT_MODIFY_WINDOW, OPT_IGNORE_EXISTING};
static char *short_options = "oblLWHpguDCtcahvqrRIxnSe:B:T:zP";
@@ -197,6 +199,7 @@
{"server", 0, 0, OPT_SERVER},
{"sender", 0, 0, OPT_SENDER},
{"existing", 0, 0, OPT_EXISTING},
+ {"ignore-existing", 0, 0, OPT_IGNORE_EXISTING},
{"delete", 0, 0, OPT_DELETE},
{"delete-excluded", 0, 0, OPT_DELETE_EXCLUDED},
{"force", 0, 0, OPT_FORCE},
@@ -359,6 +362,10 @@
only_existing = 1;
break;
+ case OPT_IGNORE_EXISTING:
+ ignore_existing = 1;
+ break;
+
case OPT_DELETE_AFTER:
delete_after = 1;
break;
@@ -745,6 +752,9 @@
if (only_existing && am_sender)
args[ac++] = "--existing";
+
+ if (ignore_existing && am_sender)
+ args[ac++] = "--ignore-existing";
if (tmpdir) {
args[ac++] = "--temp-dir";
Common subdirectories: rsync-2.4.6/packaging and rsync-2.4.6-hacked/packaging
diff -u rsync-2.4.6/rsync.1 rsync-2.4.6-hacked/rsync.1
--- rsync-2.4.6/rsync.1 Tue Sep 5 19:46:43 2000
+++ rsync-2.4.6-hacked/rsync.1 Sat Oct 13 08:02:47 2001
@@ -274,6 +274,7 @@
--rsync-path=PATH specify path to rsync on the remote machine
-C, --cvs-exclude auto ignore files in the same way CVS does
--existing only update files that already exist
+ --ignore-existing ignore files that already exist on the receiving side
--delete delete files that don\'t exist on the sending side
--delete-excluded also delete excluded files on the receiving side
--delete-after delete after transferring, not before
@@ -513,6 +514,10 @@
.IP "\fB--existing\fP"
This tells rsync not to create any new files -
only update files that already exist on the destination\&.
+.IP
+.IP "\fB--ignore-existing\fP"
+This tells rsync not to update files that already exist on
+the destination.
.IP
.IP "\fB--max-delete=NUM\fP"
This tells rsync not to delete more than NUM
Common subdirectories: rsync-2.4.6/zlib and rsync-2.4.6-hacked/zlib
More information about the rsync
mailing list