1 After applying this patch and running configure, you MUST run this
7 --- io.c 8 May 2004 18:03:43 -0000 1.120
8 +++ io.c 13 May 2004 18:57:54 -0000
9 @@ -222,6 +222,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 @@ -637,6 +645,16 @@ static int read_unbuffered(int fd, char
26 read_loop(fd, buffer, remaining);
30 + if (remaining != 4) {
31 + rprintf(FERROR, "invalid multi-message %d:%ld\n",
32 + tag, (long)remaining);
33 + exit_cleanup(RERR_STREAMIO);
35 + read_loop(fd, line, remaining);
36 + successful_send(IVAL(line, 0));
41 --- main.c 10 Feb 2004 03:54:47 -0000 1.192
42 +++ main.c 13 May 2004 18:57:54 -0000
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 preserve_hard_links;
50 extern int protocol_version;
51 @@ -567,6 +568,8 @@ void start_server(int f_in, int f_out, i
52 io_start_multiplex_out(f_out);
55 + if (need_messages_from_generator)
56 + io_start_multiplex_in(f_in);
58 recv_exclude_list(f_in);
60 @@ -632,6 +635,9 @@ int client_run(int f_in, int f_out, pid_
65 + if (need_messages_from_generator)
66 + io_start_multiplex_out(f_out);
70 --- options.c 6 May 2004 21:08:01 -0000 1.148
71 +++ options.c 13 May 2004 18:57:55 -0000
72 @@ -84,6 +84,7 @@ int copy_unsafe_links = 0;
76 +int delete_sent_files = 0;
77 int only_existing = 0;
78 int opt_ignore_existing = 0;
80 @@ -91,6 +92,7 @@ int ignore_errors = 0;
81 int modify_window = 0;
83 int checksum_seed = 0;
84 +int need_messages_from_generator = 0;
85 unsigned int block_size = 0;
88 @@ -254,6 +256,7 @@ void usage(enum logcode F)
89 rprintf(F," --delete delete files that don't exist on the sending side\n");
90 rprintf(F," --delete-excluded also delete excluded files on the receiving side\n");
91 rprintf(F," --delete-after receiver deletes after transferring, not before\n");
92 + rprintf(F," --delete-sent-files updated/sent files are removed from sending side\n");
93 rprintf(F," --ignore-errors delete even if there are I/O errors\n");
94 rprintf(F," --max-delete=NUM don't delete more than NUM files\n");
95 rprintf(F," --partial keep partially transferred files\n");
96 @@ -303,8 +306,8 @@ void usage(enum logcode F)
99 enum {OPT_VERSION = 1000, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
100 - OPT_DELETE_AFTER, OPT_DELETE_EXCLUDED, OPT_LINK_DEST,
101 - OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
102 + OPT_DELETE_AFTER, OPT_DELETE_EXCLUDED, OPT_DELETE_SENT_FILES,
103 + OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_LINK_DEST, OPT_MODIFY_WINDOW,
104 OPT_READ_BATCH, OPT_WRITE_BATCH,
105 OPT_REFUSED_BASE = 9000};
107 @@ -323,6 +326,7 @@ static struct poptOption long_options[]
108 {"ignore-existing", 0, POPT_ARG_NONE, &opt_ignore_existing, 0, 0, 0 },
109 {"delete-after", 0, POPT_ARG_NONE, 0, OPT_DELETE_AFTER, 0, 0 },
110 {"delete-excluded", 0, POPT_ARG_NONE, 0, OPT_DELETE_EXCLUDED, 0, 0 },
111 + {"delete-sent-files",0, POPT_ARG_NONE, 0, OPT_DELETE_SENT_FILES, 0, 0 },
112 {"force", 0, POPT_ARG_NONE, &force_delete, 0, 0, 0 },
113 {"numeric-ids", 0, POPT_ARG_NONE, &numeric_ids, 0, 0, 0 },
114 {"exclude", 0, POPT_ARG_STRING, 0, OPT_EXCLUDE, 0, 0 },
115 @@ -509,6 +513,11 @@ int parse_arguments(int *argc, const cha
119 + case OPT_DELETE_SENT_FILES:
120 + delete_sent_files = 1;
121 + need_messages_from_generator = 1;
125 add_exclude(&exclude_list, poptGetOptArg(pc), 0);
127 @@ -964,6 +973,9 @@ void server_options(char **args,int *arg
128 args[ac++] = "--from0";
132 + if (delete_sent_files)
133 + args[ac++] = "--delete-sent-files";
137 --- receiver.c 13 May 2004 07:08:22 -0000 1.77
138 +++ receiver.c 13 May 2004 18:57:55 -0000
139 @@ -46,6 +46,7 @@ extern int module_id;
140 extern int ignore_errors;
141 extern int orig_umask;
142 extern int keep_partial;
143 +extern int delete_sent_files;
145 static void delete_one(char *fn, int is_dir)
147 @@ -293,7 +294,7 @@ int recv_files(int f_in,struct file_list
148 char *fname, fbuf[MAXPATHLEN];
149 char template[MAXPATHLEN];
150 char fnametmp[MAXPATHLEN];
152 + char *fnamecmp, numbuf[4];
153 char fnamecmpbuf[MAXPATHLEN];
154 struct map_struct *mapbuf;
156 @@ -475,16 +476,20 @@ int recv_files(int f_in,struct file_list
162 + if (delete_sent_files) {
163 + SIVAL(numbuf, 0, i);
164 + send_msg(MSG_SUCCESS, numbuf, 4);
167 if (csum_length == SUM_LENGTH) {
168 rprintf(FERROR,"ERROR: file corruption in %s. File changed during transfer?\n",
173 rprintf(FINFO,"redoing %s(%d)\n",fname,i);
175 - send_msg(MSG_REDO, buf, 4);
176 + SIVAL(numbuf, 0, i);
177 + send_msg(MSG_REDO, numbuf, 4);
181 --- rsync.h 13 May 2004 18:51:22 -0000 1.203
182 +++ rsync.h 13 May 2004 18:57:55 -0000
184 #define FLAG_TOP_DIR (1<<0)
185 #define FLAG_HLINK_EOL (1<<1) /* generator only */
186 #define FLAG_MOUNT_POINT (1<<2) /* sender only */
187 +#define FLAG_SENT (1<<7) /* sender only */
189 /* update this if you make incompatible changes */
190 #define PROTOCOL_VERSION 28
191 @@ -123,6 +124,7 @@ enum logcode { FERROR=1, FINFO=2, FLOG=3
192 /* Messages types that are sent over the message channel. The logcode
193 * values must all be present here with identical numbers. */
195 + MSG_SUCCESS=6, /* successfully updated indicated flist index */
196 MSG_DONE=5, /* current phase is done */
197 MSG_REDO=4, /* reprocess indicated flist index */
198 MSG_ERROR=FERROR, MSG_INFO=FINFO, MSG_LOG=FLOG, /* remote logging */
199 --- rsync.yo 7 May 2004 00:18:37 -0000 1.169
200 +++ rsync.yo 13 May 2004 18:57:56 -0000
201 @@ -312,6 +312,7 @@ verb(
202 --delete delete files that don't exist on sender
203 --delete-excluded also delete excluded files on receiver
204 --delete-after receiver deletes after transfer, not before
205 + --delete-sent-files updated/sent files are removed from sender
206 --ignore-errors delete even if there are I/O errors
207 --max-delete=NUM don't delete more than NUM files
208 --partial keep partially transferred files
209 @@ -596,6 +597,11 @@ dit(bf(--delete-after)) By default rsync
210 receiving side before transferring files to try to ensure that there is
211 sufficient space on the receiving filesystem. If you want to delete
212 after transferring, use the --delete-after switch. Implies --delete.
214 +dit(bf(--delete-sent-files)) This tells rsync to remove the source files
215 +on the sending side that are successfully transferred to the receiving
216 +side. Directories are not removed, nor are files that are identical on
219 dit(bf(--ignore-errors)) Tells --delete to go ahead and delete files
220 even when there are I/O errors.
221 --- sender.c 11 May 2004 19:53:16 -0000 1.39
222 +++ sender.c 13 May 2004 18:57:56 -0000
223 @@ -27,6 +27,7 @@ extern int dry_run;
224 extern int am_server;
225 extern int am_daemon;
226 extern int protocol_version;
227 +extern int delete_sent_files;
231 @@ -104,7 +105,29 @@ static struct sum_struct *receive_sums(i
235 +static struct file_list *the_flist;
237 +void successful_send(int i)
239 + char fname[MAXPATHLEN];
240 + struct file_struct *file;
241 + unsigned int offset;
246 + file = the_flist->files[i];
247 + if (!(file->flags & FLAG_SENT))
248 + return; /* We didn't send it -- impossible! */
249 + if (file->basedir) {
250 + offset = stringjoin(fname, sizeof fname,
251 + file->basedir, "/", NULL);
254 + f_name_to(file, fname + offset);
255 + if (delete_sent_files && do_unlink(fname) == 0 && verbose > 0)
256 + rprintf(FINFO, "sender removed %s\n", fname + offset);
259 void send_files(struct file_list *flist, int f_out, int f_in)
261 @@ -129,6 +152,8 @@ void send_files(struct file_list *flist,
263 rprintf(FINFO, "send_files starting\n");
270 @@ -299,6 +324,9 @@ void send_files(struct file_list *flist,
273 rprintf(FINFO, "sender finished %s\n", fname);
275 + /* Flag that we actually sent this entry. */
276 + file->flags |= FLAG_SENT;