1 After applying this patch and running configure, you MUST run this
7 --- orig/io.c 2004-08-02 02:44:26
8 +++ io.c 2004-07-03 20:17:10
9 @@ -240,6 +240,14 @@ static void read_msg_fd(void)
10 read_loop(fd, buf, 4);
11 redo_list_add(IVAL(buf,0));
15 + rprintf(FERROR, "invalid message %d:%d\n", tag, len);
16 + exit_cleanup(RERR_STREAMIO);
18 + read_loop(fd, buf, len);
19 + io_multiplex_write(MSG_SUCCESS, buf, len);
24 @@ -673,6 +681,16 @@ static int readfd_unbuffered(int fd, cha
25 read_loop(fd, iobuf_in, remaining);
29 + if (remaining != 4) {
30 + rprintf(FERROR, "invalid multi-message %d:%ld\n",
31 + tag, (long)remaining);
32 + exit_cleanup(RERR_STREAMIO);
34 + read_loop(fd, line, remaining);
35 + successful_send(IVAL(line, 0));
40 if (remaining >= sizeof line) {
41 --- orig/main.c 2004-08-05 18:24:21
42 +++ main.c 2004-07-22 03:06:20
43 @@ -42,6 +42,7 @@ extern int list_only;
44 extern int local_server;
45 extern int log_got_error;
47 +extern int need_messages_from_generator;
48 extern int orig_umask;
49 extern int copy_links;
50 extern int keep_dirlinks;
51 @@ -621,6 +622,8 @@ void start_server(int f_in, int f_out, i
54 keep_dirlinks = 0; /* Must be disabled on the sender. */
55 + if (need_messages_from_generator)
56 + io_start_multiplex_in(f_in);
58 recv_exclude_list(f_in);
60 @@ -692,6 +695,9 @@ int client_run(int f_in, int f_out, pid_
64 + if (need_messages_from_generator && !read_batch)
65 + io_start_multiplex_out(f_out);
70 --- orig/options.c 2004-08-11 23:42:23
71 +++ options.c 2004-07-16 20:09:54
72 @@ -87,8 +87,10 @@ int size_only = 0;
74 size_t bwlimit_writemax = 0;
76 +int delete_sent_files = 0;
77 int only_existing = 0;
78 int opt_ignore_existing = 0;
79 +int need_messages_from_generator = 0;
81 int ignore_errors = 0;
82 int modify_window = 0;
83 @@ -266,6 +268,7 @@ void usage(enum logcode F)
84 rprintf(F," --delete delete files that don't exist on the sending side\n");
85 rprintf(F," --delete-excluded also delete excluded files on the receiving side\n");
86 rprintf(F," --delete-after receiver deletes after transferring, not before\n");
87 + rprintf(F," --delete-sent-files updated/sent files are removed from sending side\n");
88 rprintf(F," --ignore-errors delete even if there are I/O errors\n");
89 rprintf(F," --max-delete=NUM don't delete more than NUM files\n");
90 rprintf(F," --partial keep partially transferred files\n");
91 @@ -317,8 +320,8 @@ void usage(enum logcode F)
94 enum {OPT_VERSION = 1000, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
95 - OPT_DELETE_AFTER, OPT_DELETE_EXCLUDED, OPT_LINK_DEST,
96 - OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
97 + OPT_DELETE_AFTER, OPT_DELETE_EXCLUDED, OPT_DELETE_SENT_FILES,
98 + OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_LINK_DEST, OPT_MODIFY_WINDOW,
99 OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_TIMEOUT,
100 OPT_REFUSED_BASE = 9000};
102 @@ -337,6 +340,7 @@ static struct poptOption long_options[]
103 {"ignore-existing", 0, POPT_ARG_NONE, &opt_ignore_existing, 0, 0, 0 },
104 {"delete-after", 0, POPT_ARG_NONE, 0, OPT_DELETE_AFTER, 0, 0 },
105 {"delete-excluded", 0, POPT_ARG_NONE, 0, OPT_DELETE_EXCLUDED, 0, 0 },
106 + {"delete-sent-files",0, POPT_ARG_NONE, 0, OPT_DELETE_SENT_FILES, 0, 0 },
107 {"force", 0, POPT_ARG_NONE, &force_delete, 0, 0, 0 },
108 {"numeric-ids", 0, POPT_ARG_NONE, &numeric_ids, 0, 0, 0 },
109 {"exclude", 0, POPT_ARG_STRING, 0, OPT_EXCLUDE, 0, 0 },
110 @@ -539,6 +543,11 @@ int parse_arguments(int *argc, const cha
114 + case OPT_DELETE_SENT_FILES:
115 + delete_sent_files = 1;
116 + need_messages_from_generator = 1;
120 if (am_server || sanitize_paths)
121 return 0; /* Impossible... */
122 @@ -1090,6 +1099,9 @@ void server_options(char **args,int *arg
126 + if (delete_sent_files)
127 + args[ac++] = "--delete-sent-files";
132 --- orig/receiver.c 2004-08-03 15:34:32
133 +++ receiver.c 2004-07-29 16:11:11
134 @@ -45,6 +45,7 @@ extern char *backup_dir;
135 extern char *backup_suffix;
136 extern int backup_suffix_len;
137 extern int cleanup_got_literal;
138 +extern int delete_sent_files;
139 extern int module_id;
140 extern int ignore_errors;
141 extern int orig_umask;
142 @@ -341,7 +342,7 @@ int recv_files(int f_in, struct file_lis
143 char *fname, fbuf[MAXPATHLEN];
144 char template[MAXPATHLEN];
145 char fnametmp[MAXPATHLEN];
146 - char *fnamecmp, *partialptr;
147 + char *fnamecmp, *partialptr, numbuf[4];
148 char fnamecmpbuf[MAXPATHLEN];
149 struct file_struct *file;
150 struct stats initial_stats;
151 @@ -571,7 +572,12 @@ int recv_files(int f_in, struct file_lis
157 + if (delete_sent_files) {
158 + SIVAL(numbuf, 0, i);
159 + send_msg(MSG_SUCCESS, numbuf, 4);
162 int msgtype = csum_length == SUM_LENGTH || read_batch ?
164 if (msgtype == FERROR || verbose) {
165 @@ -595,9 +601,8 @@ int recv_files(int f_in, struct file_lis
168 if (csum_length != SUM_LENGTH) {
171 - send_msg(MSG_REDO, buf, 4);
172 + SIVAL(numbuf, 0, i);
173 + send_msg(MSG_REDO, numbuf, 4);
177 --- orig/rsync.h 2004-08-03 15:41:32
178 +++ rsync.h 2004-07-03 20:17:10
180 #define FLAG_TOP_DIR (1<<0)
181 #define FLAG_HLINK_EOL (1<<1) /* generator only */
182 #define FLAG_MOUNT_POINT (1<<2) /* sender only */
183 +#define FLAG_SENT (1<<7) /* sender only */
185 /* update this if you make incompatible changes */
186 #define PROTOCOL_VERSION 28
187 @@ -126,6 +127,7 @@ enum logcode { FERROR=1, FINFO=2, FLOG=3
188 /* Messages types that are sent over the message channel. The logcode
189 * values must all be present here with identical numbers. */
191 + MSG_SUCCESS=6, /* successfully updated indicated flist index */
192 MSG_DONE=5, /* current phase is done */
193 MSG_REDO=4, /* reprocess indicated flist index */
194 MSG_ERROR=FERROR, MSG_INFO=FINFO, MSG_LOG=FLOG, /* remote logging */
195 --- orig/rsync.yo 2004-08-11 17:26:27
196 +++ rsync.yo 2004-07-03 20:17:10
197 @@ -314,6 +314,7 @@ verb(
198 --delete delete files that don't exist on sender
199 --delete-excluded also delete excluded files on receiver
200 --delete-after receiver deletes after transfer, not before
201 + --delete-sent-files updated/sent files are removed from sender
202 --ignore-errors delete even if there are I/O errors
203 --max-delete=NUM don't delete more than NUM files
204 --partial keep partially transferred files
205 @@ -625,6 +626,11 @@ receiving side before transferring files
206 sufficient space on the receiving filesystem. If you want to delete
207 after transferring, use the --delete-after switch. Implies --delete.
209 +dit(bf(--delete-sent-files)) This tells rsync to remove the source files
210 +on the sending side that are successfully transferred to the receiving
211 +side. Directories are not removed, nor are files that are identical on
214 dit(bf(--ignore-errors)) Tells --delete to go ahead and delete files
215 even when there are I/O errors.
217 --- orig/sender.c 2004-08-03 15:34:32
218 +++ sender.c 2004-07-26 16:49:19
219 @@ -26,6 +26,7 @@ extern int io_error;
221 extern int am_server;
222 extern int am_daemon;
223 +extern int delete_sent_files;
224 extern int protocol_version;
225 extern struct stats stats;
227 @@ -107,7 +108,29 @@ static struct sum_struct *receive_sums(i
231 +static struct file_list *the_flist;
233 +void successful_send(int i)
235 + char fname[MAXPATHLEN];
236 + struct file_struct *file;
237 + unsigned int offset;
242 + file = the_flist->files[i];
243 + if (!(file->flags & FLAG_SENT))
244 + return; /* We didn't send it -- impossible! */
245 + if (file->basedir) {
246 + offset = stringjoin(fname, sizeof fname,
247 + file->basedir, "/", NULL);
250 + f_name_to(file, fname + offset);
251 + if (delete_sent_files && do_unlink(fname) == 0 && verbose > 0)
252 + rprintf(FINFO, "sender removed %s\n", fname + offset);
255 void send_files(struct file_list *flist, int f_out, int f_in)
257 @@ -125,6 +148,8 @@ void send_files(struct file_list *flist,
259 rprintf(FINFO, "send_files starting\n");
266 @@ -252,6 +277,9 @@ void send_files(struct file_list *flist,
267 rprintf(FINFO, "sender finished %s\n",
271 + /* Flag that we actually sent this entry. */
272 + file->flags |= FLAG_SENT;