--- generator.c 5 Jun 2006 16:56:50 -0000 1.283 +++ generator.c 30 Jun 2006 15:52:52 -0000 1.285 @@ -50,7 +50,7 @@ extern int delete_during; extern int delete_after; extern int module_id; extern int ignore_errors; -extern int remove_sent_files; +extern int remove_source_files; extern int delay_updates; extern int update_only; extern int ignore_existing; @@ -986,6 +986,8 @@ static void recv_generator(char *fname, itemizing, code); } + if (remove_source_files == 1) + goto return_with_success; return; } } @@ -1025,13 +1027,10 @@ static void recv_generator(char *fname, rprintf(code, "%s -> %s\n", fname, file->u.link); } - if (remove_sent_files && !dry_run) { - char numbuf[4]; - SIVAL(numbuf, 0, ndx); - send_msg(MSG_SUCCESS, numbuf, 4); - } if (preserve_hard_links && file->link_u.links) hard_link_cluster(file, ndx, itemizing, code); + if (remove_source_files) + goto return_with_success; } #endif return; @@ -1085,6 +1084,8 @@ static void recv_generator(char *fname, hard_link_cluster(file, ndx, itemizing, code); } + if (remove_source_files == 1) + goto return_with_success; } } else { if (itemizing) @@ -1092,6 +1093,8 @@ static void recv_generator(char *fname, set_file_attrs(fname, file, &st, maybe_ATTRS_REPORT); if (preserve_hard_links && file->link_u.links) hard_link_cluster(file, ndx, itemizing, code); + if (remove_source_files == 1) + goto return_with_success; } return; } @@ -1146,8 +1149,11 @@ static void recv_generator(char *fname, if (statret != 0 && basis_dir[0] != NULL) { int j = try_dests_reg(file, fname, ndx, fnamecmpbuf, &st, itemizing, maybe_ATTRS_REPORT, code); - if (j == -2) + if (j == -2) { + if (remove_source_files == 1) + goto return_with_success; return; + } if (j != -1) { fnamecmp = fnamecmpbuf; fnamecmp_type = j; @@ -1213,6 +1219,14 @@ static void recv_generator(char *fname, set_file_attrs(fname, file, &st, maybe_ATTRS_REPORT); if (preserve_hard_links && file->link_u.links) hard_link_cluster(file, ndx, itemizing, code); + if (remove_source_files != 1) + return; + return_with_success: + if (!dry_run) { + char numbuf[4]; + SIVAL(numbuf, 0, ndx); + send_msg(MSG_SUCCESS, numbuf, 4); + } return; } @@ -1285,8 +1299,8 @@ static void recv_generator(char *fname, rprintf(FINFO, "generating and sending sums for %d\n", ndx); notify_others: - if (remove_sent_files && !delay_updates && !phase) - increment_active_files(ndx, itemizing, code); + if (remove_source_files && !delay_updates && !phase) + increment_active_files(ndx, itemizing, code); write_int(f_out, ndx); if (itemizing) { int iflags = ITEM_TRANSFER; --- hlink.c 29 May 2006 22:56:55 -0000 1.61 +++ hlink.c 30 Jun 2006 15:52:52 -0000 1.63 @@ -24,8 +24,10 @@ #include "rsync.h" extern int verbose; +extern int do_xfers; extern int link_dest; extern int make_backups; +extern int remove_source_files; extern int stdout_format_has_i; extern char *basis_dir[]; extern struct file_list *the_file_list; @@ -222,6 +224,11 @@ int hard_link_check(struct file_struct * } maybe_hard_link(file, ndx, fname, statret, st, toname, &st2, itemizing, code); + if (remove_source_files == 1 && do_xfers) { + char numbuf[4]; + SIVAL(numbuf, 0, ndx); + send_msg(MSG_SUCCESS, numbuf, 4); + } file->F_HLINDEX = FINISHED_LINK; } else file->F_HLINDEX = SKIPPED_LINK; @@ -287,6 +294,11 @@ void hard_link_cluster(struct file_struc statret = link_stat(hlink2, &st2, 0); maybe_hard_link(file, ndx, hlink2, statret, &st2, hlink1, &st1, itemizing, code); + if (remove_source_files == 1 && do_xfers) { + char numbuf[4]; + SIVAL(numbuf, 0, ndx); + send_msg(MSG_SUCCESS, numbuf, 4); + } file->F_HLINDEX = FINISHED_LINK; } while (!(file->flags & FLAG_HLINK_EOL)); #endif --- io.c 3 May 2006 16:17:46 -0000 1.196 +++ io.c 30 Jun 2006 15:52:52 -0000 1.198 @@ -46,7 +46,7 @@ extern int read_batch; extern int csum_length; extern int checksum_seed; extern int protocol_version; -extern int remove_sent_files; +extern int remove_source_files; extern int preserve_hard_links; extern char *filesfrom_host; extern struct stats stats; @@ -257,7 +257,7 @@ static void read_msg_fd(void) exit_cleanup(RERR_STREAMIO); } read_loop(fd, buf, 4); - if (remove_sent_files) + if (remove_source_files) decrement_active_files(IVAL(buf,0)); flist_ndx_push(&redo_list, IVAL(buf,0)); break; @@ -275,7 +275,7 @@ static void read_msg_fd(void) exit_cleanup(RERR_STREAMIO); } read_loop(fd, buf, len); - if (remove_sent_files) { + if (remove_source_files) { decrement_active_files(IVAL(buf,0)); send_msg(MSG_SUCCESS, buf, len); } @@ -311,7 +311,7 @@ static void read_msg_fd(void) } /* This is used by the generator to limit how many file transfers can - * be active at once when --remove-sent-files is specified. Without + * be active at once when --remove-source-files is specified. Without * this, sender-side deletions were mostly happening at the end. */ void increment_active_files(int ndx, int itemizing, enum logcode code) { --- main.c 5 Jun 2006 22:50:52 -0000 1.310 +++ main.c 30 Jun 2006 15:52:52 -0000 1.312 @@ -35,7 +35,7 @@ extern int am_sender; extern int am_generator; extern int am_daemon; extern int blocking_io; -extern int remove_sent_files; +extern int remove_source_files; extern int daemon_over_rsh; extern int need_messages_from_generator; extern int kluge_around_eof; @@ -614,9 +614,10 @@ static void do_server_sender(int f_in, i exit_cleanup(RERR_SYNTAX); return; } - if (am_daemon && lp_read_only(module_id) && remove_sent_files) { + if (am_daemon && lp_read_only(module_id) && remove_source_files) { rprintf(FERROR, - "ERROR: --remove-sent-files cannot be used with a read-only module\n"); + "ERROR: --remove-%s-files cannot be used with a read-only module\n", + remove_source_files == 1 ? "source" : "sent"); exit_cleanup(RERR_SYNTAX); return; } --- options.c 7 Jun 2006 23:05:24 -0000 1.346 +++ options.c 30 Jun 2006 15:52:52 -0000 1.348 @@ -65,7 +65,7 @@ int delete_during = 0; int delete_before = 0; int delete_after = 0; int delete_excluded = 0; -int remove_sent_files = 0; +int remove_source_files = 0; int one_file_system = 0; int protocol_version = PROTOCOL_VERSION; int sparse_files = 0; @@ -321,7 +321,7 @@ void usage(enum logcode F) rprintf(F," --rsync-path=PROGRAM specify the rsync to run on the remote machine\n"); rprintf(F," --existing skip creating new files on receiver\n"); rprintf(F," --ignore-existing skip updating files that already exist on receiver\n"); - rprintf(F," --remove-sent-files sender removes successfully sent files (non-dirs)\n"); + rprintf(F," --remove-source-files sender removes synchronized files (non-dirs)\n"); rprintf(F," --del an alias for --delete-during\n"); rprintf(F," --delete delete extraneous files from destination dirs\n"); rprintf(F," --delete-before receiver deletes before transfer (default)\n"); @@ -475,7 +475,8 @@ static struct poptOption long_options[] {"delete-during", 0, POPT_ARG_NONE, &delete_during, 0, 0, 0 }, {"delete-after", 0, POPT_ARG_NONE, &delete_after, 0, 0, 0 }, {"delete-excluded", 0, POPT_ARG_NONE, &delete_excluded, 0, 0, 0 }, - {"remove-sent-files",0, POPT_ARG_NONE, &remove_sent_files, 0, 0, 0 }, + {"remove-sent-files",0, POPT_ARG_VAL, &remove_source_files, 2, 0, 0 }, /* deprecated */ + {"remove-source-files",0,POPT_ARG_VAL, &remove_source_files, 1, 0, 0 }, {"force", 0, POPT_ARG_NONE, &force_delete, 0, 0, 0 }, {"ignore-errors", 0, POPT_ARG_NONE, &ignore_errors, 0, 0, 0 }, {"max-delete", 0, POPT_ARG_INT, &max_delete, 0, 0, 0 }, @@ -1204,8 +1205,8 @@ int parse_arguments(int *argc, const cha return 0; } - if (remove_sent_files) { - /* We only want to infer this refusal of --remove-sent-files + if (remove_source_files) { + /* We only want to infer this refusal of --remove-source-files * via the refusal of "delete", not any of the "delete-FOO" * options. */ if (refused_delete && am_sender) { @@ -1756,7 +1757,9 @@ void server_options(char **args,int *arg if (fuzzy_basis && am_sender) args[ac++] = "--fuzzy"; - if (remove_sent_files) + if (remove_source_files == 1) + args[ac++] = "--remove-source-files"; + else if (remove_source_files) args[ac++] = "--remove-sent-files"; *argc = ac; --- receiver.c 1 Jun 2006 08:04:50 -0000 1.181 +++ receiver.c 30 Jun 2006 15:52:52 -0000 1.183 @@ -40,7 +40,7 @@ extern int preserve_perms; extern int basis_dir_cnt; extern int make_backups; extern int cleanup_got_literal; -extern int remove_sent_files; +extern int remove_source_files; extern int append_mode; extern int sparse_files; extern int keep_partial; @@ -296,7 +296,7 @@ static void handle_delayed_updates(struc "rename failed for %s (from %s)", full_fname(fname), partialptr); } else { - if (remove_sent_files + if (remove_source_files || (preserve_hard_links && file->link_u.links)) { SIVAL(numbuf, 0, i); @@ -644,7 +644,7 @@ int recv_files(int f_in, struct file_lis cleanup_disable(); if (recv_ok > 0) { - if (remove_sent_files + if (remove_source_files || (preserve_hard_links && file->link_u.links)) { SIVAL(numbuf, 0, i); send_msg(MSG_SUCCESS, numbuf, 4); --- rsync.yo 30 May 2006 17:47:20 -0000 1.374 +++ rsync.yo 30 Jun 2006 15:52:52 -0000 1.376 @@ -339,7 +339,7 @@ to the detailed description below for a --rsync-path=PROGRAM specify the rsync to run on remote machine --existing skip creating new files on receiver --ignore-existing skip updating files that exist on receiver - --remove-sent-files sender removes successfully sent files + --remove-source-files sender removes synchronized files (non-dir) --del an alias for --delete-during --delete delete extraneous files from dest dirs --delete-before receiver deletes before transfer (default) @@ -918,10 +918,9 @@ dit(bf(--ignore-existing)) This tells rs already exist on the destination (this does em(not) ignore existing directores, or nothing would get done). See also bf(--existing). -dit(bf(--remove-sent-files)) This tells rsync to remove from the sending -side the files and/or symlinks that are newly created or whose content is -updated on the receiving side. Directories and devices are not removed, -nor are files/symlinks whose attributes are merely changed. +dit(bf(--remove-source-files)) This tells rsync to remove from the sending +side the files (meaning non-directories) that are a part of the transfer +and have been successfully duplicated on the receiving side. dit(bf(--delete)) This tells rsync to delete extraneous files from the receiving side (ones that aren't on the sending side), but only for the --- rsync.1 30 May 2006 17:47:20 -0000 1.386 +++ rsync.1 30 Jun 2006 15:52:52 -0000 1.388 @@ -395,7 +395,7 @@ to the detailed description below for a --rsync-path=PROGRAM specify the rsync to run on remote machine --existing skip creating new files on receiver --ignore-existing skip updating files that exist on receiver - --remove-sent-files sender removes successfully sent files + --remove-source-files sender removes synchronized files (non-dir) --del an alias for --delete-during --delete delete extraneous files from dest dirs --delete-before receiver deletes before transfer (default) @@ -1045,11 +1045,10 @@ This tells rsync to skip updating files already exist on the destination (this does \fInot\fP ignore existing directores, or nothing would get done)\&. See also \fB--existing\fP\&. .IP -.IP "\fB--remove-sent-files\fP" +.IP "\fB--remove-source-files\fP" This tells rsync to remove from the sending -side the files and/or symlinks that are newly created or whose content is -updated on the receiving side\&. Directories and devices are not removed, -nor are files/symlinks whose attributes are merely changed\&. +side the files (meaning non-directories) that are a part of the transfer +and have been successfully duplicated on the receiving side\&. .IP .IP "\fB--delete\fP" This tells rsync to delete extraneous files from the --- sender.c 1 Jun 2006 08:04:50 -0000 1.97 +++ sender.c 30 Jun 2006 15:52:52 -0000 1.99 @@ -34,7 +34,7 @@ extern int append_mode; extern int io_error; extern int allowed_lull; extern int protocol_version; -extern int remove_sent_files; +extern int remove_source_files; extern int updating_basis_file; extern int make_backups; extern int do_progress; @@ -128,16 +128,13 @@ void successful_send(int ndx) return; file = the_file_list->files[ndx]; - /* The generator might tell us about symlinks we didn't send. */ - if (!(file->flags & FLAG_SENT) && !S_ISLNK(file->mode)) - return; if (file->dir.root) { offset = stringjoin(fname, sizeof fname, file->dir.root, "/", NULL); } else offset = 0; f_name(file, fname + offset); - if (remove_sent_files && do_unlink(fname) == 0 && verbose > 1) + if (remove_source_files && do_unlink(fname) == 0 && verbose > 1) rprintf(FINFO, "sender removed %s\n", fname + offset); }