Commit | Line | Data |
---|---|---|
8a529471 WD |
1 | After applying this patch and running configure, you MUST run this |
2 | command before "make": | |
3 | ||
4 | make proto | |
5 | ||
6 | ||
d1cfcd41 | 7 | --- orig/io.c 2005-02-03 02:04:20 |
4945df2c | 8 | +++ io.c 2005-01-10 10:49:17 |
0b2fb126 | 9 | @@ -244,6 +244,14 @@ static void read_msg_fd(void) |
c57f4101 WD |
10 | read_loop(fd, buf, 4); |
11 | redo_list_add(IVAL(buf,0)); | |
12 | break; | |
13 | + case MSG_SUCCESS: | |
14 | + if (len != 4) { | |
15 | + rprintf(FERROR, "invalid message %d:%d\n", tag, len); | |
16 | + exit_cleanup(RERR_STREAMIO); | |
17 | + } | |
18 | + read_loop(fd, buf, len); | |
19 | + io_multiplex_write(MSG_SUCCESS, buf, len); | |
20 | + break; | |
21 | case MSG_INFO: | |
22 | case MSG_ERROR: | |
23 | case MSG_LOG: | |
0b2fb126 | 24 | @@ -677,6 +685,16 @@ static int readfd_unbuffered(int fd, cha |
9cd8d7aa WD |
25 | read_loop(fd, iobuf_in, remaining); |
26 | iobuf_in_ndx = 0; | |
7b675ff5 | 27 | break; |
c57f4101 WD |
28 | + case MSG_SUCCESS: |
29 | + if (remaining != 4) { | |
30 | + rprintf(FERROR, "invalid multi-message %d:%ld\n", | |
31 | + tag, (long)remaining); | |
32 | + exit_cleanup(RERR_STREAMIO); | |
33 | + } | |
34 | + read_loop(fd, line, remaining); | |
35 | + successful_send(IVAL(line, 0)); | |
36 | + remaining = 0; | |
7b675ff5 | 37 | + break; |
c57f4101 WD |
38 | case MSG_INFO: |
39 | case MSG_ERROR: | |
7b675ff5 | 40 | if (remaining >= sizeof line) { |
f9d7f3e9 | 41 | --- orig/main.c 2005-02-15 19:27:04 |
c5a8a208 | 42 | +++ main.c 2005-02-05 01:24:16 |
f9d7f3e9 WD |
43 | @@ -33,12 +33,14 @@ extern int verbose; |
44 | extern int itemize_changes; | |
c5a8a208 | 45 | extern int blocking_io; |
8af144e1 | 46 | extern int delete_before; |
8af144e1 WD |
47 | +extern int delete_sent_files; |
48 | extern int daemon_over_rsh; | |
49 | extern int do_stats; | |
50 | extern int dry_run; | |
c5a8a208 | 51 | extern int list_only; |
c57f4101 WD |
52 | extern int log_got_error; |
53 | extern int module_id; | |
54 | +extern int need_messages_from_generator; | |
55 | extern int orig_umask; | |
d5753a22 | 56 | extern int copy_links; |
7628f156 | 57 | extern int keep_dirlinks; |
f9d7f3e9 | 58 | @@ -442,6 +444,12 @@ static void do_server_sender(int f_in, i |
8af144e1 WD |
59 | exit_cleanup(RERR_SYNTAX); |
60 | return; | |
61 | } | |
62 | + if (am_daemon && lp_read_only(module_id) && delete_sent_files) { | |
63 | + rprintf(FERROR, | |
64 | + "ERROR: --delete-sent-files cannot be used with a read-only module\n"); | |
65 | + exit_cleanup(RERR_SYNTAX); | |
66 | + return; | |
67 | + } | |
68 | ||
69 | if (!relative_paths && !push_dir(dir)) { | |
70 | rsyserr(FERROR, errno, "push_dir#3 %s failed", | |
f9d7f3e9 | 71 | @@ -673,6 +681,8 @@ void start_server(int f_in, int f_out, i |
c57f4101 WD |
72 | |
73 | if (am_sender) { | |
7628f156 | 74 | keep_dirlinks = 0; /* Must be disabled on the sender. */ |
c57f4101 | 75 | + if (need_messages_from_generator) |
580f70f0 | 76 | + io_start_multiplex_in(); |
9be39c35 | 77 | |
4f9b6a01 | 78 | recv_filter_list(f_in); |
c5a8a208 | 79 | do_server_sender(f_in, f_out, argc, argv); |
f9d7f3e9 | 80 | @@ -750,6 +760,9 @@ int client_run(int f_in, int f_out, pid_ |
c57f4101 WD |
81 | exit_cleanup(status); |
82 | } | |
7b675ff5 | 83 | |
dc8e6f70 | 84 | + if (need_messages_from_generator && !read_batch) |
580f70f0 | 85 | + io_start_multiplex_out(); |
7b675ff5 | 86 | + |
fe6407b5 | 87 | if (argc == 0) |
786384c2 | 88 | list_only |= 1; |
7b675ff5 | 89 | |
f9d7f3e9 | 90 | --- orig/options.c 2005-02-15 19:27:05 |
caf2928e | 91 | +++ options.c 2005-02-14 17:48:01 |
c5a8a208 | 92 | @@ -59,6 +59,7 @@ int delete_during = 0; |
786384c2 | 93 | int delete_before = 0; |
c57f4101 | 94 | int delete_after = 0; |
786384c2 | 95 | int delete_excluded = 0; |
c57f4101 | 96 | +int delete_sent_files = 0; |
786384c2 WD |
97 | int one_file_system = 0; |
98 | int protocol_version = PROTOCOL_VERSION; | |
99 | int sparse_files = 0; | |
3d1facaa | 100 | @@ -93,6 +94,7 @@ int fuzzy_basis = 0; |
786384c2 | 101 | size_t bwlimit_writemax = 0; |
c57f4101 WD |
102 | int only_existing = 0; |
103 | int opt_ignore_existing = 0; | |
f6c3b300 | 104 | +int need_messages_from_generator = 0; |
c57f4101 | 105 | int max_delete = 0; |
58a9031f | 106 | OFF_T max_size = 0; |
f6c3b300 | 107 | int ignore_errors = 0; |
f9d7f3e9 | 108 | @@ -291,6 +293,7 @@ void usage(enum logcode F) |
ac23c334 WD |
109 | rprintf(F," --delete-during receiver deletes during transfer, not before\n"); |
110 | rprintf(F," --delete-after receiver deletes after transfer, not before\n"); | |
786384c2 | 111 | rprintf(F," --delete-excluded also delete excluded files on the receiving side\n"); |
c57f4101 WD |
112 | + rprintf(F," --delete-sent-files updated/sent files are removed from sending side\n"); |
113 | rprintf(F," --ignore-errors delete even if there are I/O errors\n"); | |
786384c2 | 114 | rprintf(F," --force force deletion of directories even if not empty\n"); |
c57f4101 | 115 | rprintf(F," --max-delete=NUM don't delete more than NUM files\n"); |
f9d7f3e9 | 116 | @@ -368,6 +371,7 @@ static struct poptOption long_options[] |
ac23c334 | 117 | {"delete-during", 0, POPT_ARG_NONE, &delete_during, 0, 0, 0 }, |
786384c2 WD |
118 | {"delete-after", 0, POPT_ARG_NONE, &delete_after, 0, 0, 0 }, |
119 | {"delete-excluded", 0, POPT_ARG_NONE, &delete_excluded, 0, 0, 0 }, | |
4945df2c | 120 | + {"delete-sent-files",0, POPT_ARG_NONE, &delete_sent_files, 0, 0, 0 }, |
c57f4101 WD |
121 | {"force", 0, POPT_ARG_NONE, &force_delete, 0, 0, 0 }, |
122 | {"numeric-ids", 0, POPT_ARG_NONE, &numeric_ids, 0, 0, 0 }, | |
ac23c334 | 123 | {"filter", 'f', POPT_ARG_STRING, 0, OPT_FILTER, 0, 0 }, |
f9d7f3e9 | 124 | @@ -961,6 +965,14 @@ int parse_arguments(int *argc, const cha |
27a7053c WD |
125 | return 0; |
126 | } | |
c57f4101 | 127 | |
caf2928e WD |
128 | + if (delete_sent_files) { |
129 | + if (refused_delete) { | |
130 | + create_refuse_error(refused_delete); | |
131 | + return 0; | |
132 | + } | |
4945df2c | 133 | + need_messages_from_generator = 1; |
caf2928e | 134 | + } |
c57f4101 | 135 | + |
4945df2c WD |
136 | *argv = poptGetArgs(pc); |
137 | *argc = count_args(*argv); | |
138 | ||
f9d7f3e9 | 139 | @@ -1393,6 +1405,9 @@ void server_options(char **args,int *arg |
3d1facaa WD |
140 | if (fuzzy_basis && am_sender) |
141 | args[ac++] = "--fuzzy"; | |
7b675ff5 | 142 | |
c57f4101 WD |
143 | + if (delete_sent_files) |
144 | + args[ac++] = "--delete-sent-files"; | |
7b675ff5 | 145 | + |
c57f4101 WD |
146 | *argc = ac; |
147 | return; | |
7b675ff5 | 148 | |
f9d7f3e9 | 149 | --- orig/receiver.c 2005-02-15 19:27:05 |
580f70f0 | 150 | +++ receiver.c 2004-08-13 08:38:51 |
f9d7f3e9 | 151 | @@ -42,6 +42,7 @@ extern int basis_dir_cnt; |
b76d92e6 WD |
152 | extern int make_backups; |
153 | extern int do_progress; | |
f6c3b300 | 154 | extern int cleanup_got_literal; |
c57f4101 | 155 | +extern int delete_sent_files; |
f6c3b300 WD |
156 | extern int module_id; |
157 | extern int ignore_errors; | |
158 | extern int orig_umask; | |
f9d7f3e9 | 159 | @@ -307,7 +308,7 @@ int recv_files(int f_in, struct file_lis |
c57f4101 WD |
160 | char *fname, fbuf[MAXPATHLEN]; |
161 | char template[MAXPATHLEN]; | |
162 | char fnametmp[MAXPATHLEN]; | |
afbebe13 WD |
163 | - char *fnamecmp, *partialptr; |
164 | + char *fnamecmp, *partialptr, numbuf[4]; | |
c57f4101 | 165 | char fnamecmpbuf[MAXPATHLEN]; |
8af144e1 | 166 | uchar *delayed_bits = NULL; |
7628f156 | 167 | struct file_struct *file; |
f9d7f3e9 | 168 | @@ -569,7 +570,12 @@ int recv_files(int f_in, struct file_lis |
c57f4101 WD |
169 | |
170 | cleanup_disable(); | |
171 | ||
172 | - if (!recv_ok) { | |
173 | + if (recv_ok) { | |
174 | + if (delete_sent_files) { | |
175 | + SIVAL(numbuf, 0, i); | |
176 | + send_msg(MSG_SUCCESS, numbuf, 4); | |
177 | + } | |
178 | + } else { | |
8075fb75 WD |
179 | int msgtype = csum_length == SUM_LENGTH || read_batch ? |
180 | FERROR : FINFO; | |
181 | if (msgtype == FERROR || verbose) { | |
f9d7f3e9 | 182 | @@ -593,9 +599,8 @@ int recv_files(int f_in, struct file_lis |
982426b8 | 183 | keptstr, redostr); |
8075fb75 WD |
184 | } |
185 | if (csum_length != SUM_LENGTH) { | |
c57f4101 | 186 | - char buf[4]; |
c57f4101 WD |
187 | - SIVAL(buf, 0, i); |
188 | - send_msg(MSG_REDO, buf, 4); | |
189 | + SIVAL(numbuf, 0, i); | |
190 | + send_msg(MSG_REDO, numbuf, 4); | |
191 | } | |
192 | } | |
193 | } | |
f9d7f3e9 | 194 | --- orig/rsync.h 2005-02-15 19:27:05 |
d1cfcd41 | 195 | +++ rsync.h 2005-02-03 02:04:59 |
3d1facaa | 196 | @@ -62,6 +62,7 @@ |
c57f4101 | 197 | #define FLAG_MOUNT_POINT (1<<2) /* sender only */ |
3d1facaa | 198 | #define FLAG_NO_FUZZY (1<<2) /* generator only */ |
d1cfcd41 | 199 | #define FLAG_DEL_HERE (1<<3) /* receiver/generator */ |
c57f4101 WD |
200 | +#define FLAG_SENT (1<<7) /* sender only */ |
201 | ||
202 | /* update this if you make incompatible changes */ | |
0b2fb126 | 203 | #define PROTOCOL_VERSION 29 |
3d1facaa | 204 | @@ -144,6 +145,7 @@ enum logcode { FERROR=1, FINFO=2, FLOG=3 |
ea238f1c WD |
205 | /* Messages types that are sent over the message channel. The logcode |
206 | * values must all be present here with identical numbers. */ | |
207 | enum msgcode { | |
c57f4101 | 208 | + MSG_SUCCESS=6, /* successfully updated indicated flist index */ |
ea238f1c WD |
209 | MSG_DONE=5, /* current phase is done */ |
210 | MSG_REDO=4, /* reprocess indicated flist index */ | |
211 | MSG_ERROR=FERROR, MSG_INFO=FINFO, MSG_LOG=FLOG, /* remote logging */ | |
f9d7f3e9 | 212 | --- orig/rsync.yo 2005-02-15 19:27:05 |
d1cfcd41 WD |
213 | +++ rsync.yo 2005-02-03 02:05:29 |
214 | @@ -338,6 +338,7 @@ to the detailed description below for a | |
ac23c334 WD |
215 | --delete-during receiver deletes during xfer, not before |
216 | --delete-after receiver deletes after transfer, not before | |
786384c2 | 217 | --delete-excluded also delete excluded files on receiver |
c57f4101 WD |
218 | + --delete-sent-files updated/sent files are removed from sender |
219 | --ignore-errors delete even if there are I/O errors | |
786384c2 | 220 | --force force deletion of dirs even if not empty |
c57f4101 | 221 | --max-delete=NUM don't delete more than NUM files |
f9d7f3e9 | 222 | @@ -735,6 +736,11 @@ this way on the receiver, and for a way |
3d1facaa | 223 | bf(--delete-excluded). |
d1cfcd41 | 224 | See bf(--delete) (which is implied) for more details on file-deletion. |
7b675ff5 | 225 | |
c57f4101 WD |
226 | +dit(bf(--delete-sent-files)) This tells rsync to remove the source files |
227 | +on the sending side that are successfully transferred to the receiving | |
6620d4f9 WD |
228 | +side. Directories, symlinks, and devices are not removed, nor are files |
229 | +that were not transferred from the sender to the receiver. | |
7b675ff5 | 230 | + |
d1cfcd41 | 231 | dit(bf(--ignore-errors)) Tells bf(--delete) to go ahead and delete files |
c57f4101 | 232 | even when there are I/O errors. |
7b675ff5 | 233 | |
f9d7f3e9 | 234 | --- orig/sender.c 2005-02-15 19:27:05 |
982426b8 | 235 | +++ sender.c 2004-07-26 16:49:19 |
f9d7f3e9 | 236 | @@ -27,6 +27,7 @@ extern int io_error; |
f6c3b300 | 237 | extern int dry_run; |
c57f4101 WD |
238 | extern int am_server; |
239 | extern int am_daemon; | |
c57f4101 | 240 | +extern int delete_sent_files; |
f6c3b300 | 241 | extern int protocol_version; |
0b2fb126 | 242 | extern int updating_basis_file; |
a6587818 | 243 | extern int make_backups; |
f9d7f3e9 | 244 | @@ -95,7 +96,29 @@ static struct sum_struct *receive_sums(i |
c57f4101 WD |
245 | return s; |
246 | } | |
247 | ||
248 | +static struct file_list *the_flist; | |
249 | ||
250 | +void successful_send(int i) | |
251 | +{ | |
252 | + char fname[MAXPATHLEN]; | |
253 | + struct file_struct *file; | |
254 | + unsigned int offset; | |
255 | + | |
4945df2c | 256 | + if (!the_flist || i < 0 || i >= the_flist->count) |
c57f4101 WD |
257 | + return; |
258 | + | |
259 | + file = the_flist->files[i]; | |
260 | + if (!(file->flags & FLAG_SENT)) | |
261 | + return; /* We didn't send it -- impossible! */ | |
f9d7f3e9 | 262 | + if (file->dir.root) { |
c57f4101 | 263 | + offset = stringjoin(fname, sizeof fname, |
f9d7f3e9 | 264 | + file->dir.root, "/", NULL); |
c57f4101 WD |
265 | + } else |
266 | + offset = 0; | |
267 | + f_name_to(file, fname + offset); | |
6620d4f9 | 268 | + if (delete_sent_files && do_unlink(fname) == 0 && verbose) |
c57f4101 WD |
269 | + rprintf(FINFO, "sender removed %s\n", fname + offset); |
270 | +} | |
271 | ||
272 | void send_files(struct file_list *flist, int f_out, int f_in) | |
273 | { | |
f9d7f3e9 | 274 | @@ -114,6 +137,8 @@ void send_files(struct file_list *flist, |
c57f4101 WD |
275 | if (verbose > 2) |
276 | rprintf(FINFO, "send_files starting\n"); | |
277 | ||
278 | + the_flist = flist; | |
279 | + | |
280 | while (1) { | |
281 | unsigned int offset; | |
282 | ||
f9d7f3e9 | 283 | @@ -256,6 +281,9 @@ void send_files(struct file_list *flist, |
982426b8 WD |
284 | rprintf(FINFO, "sender finished %s\n", |
285 | safe_fname(fname)); | |
286 | } | |
c57f4101 WD |
287 | + |
288 | + /* Flag that we actually sent this entry. */ | |
289 | + file->flags |= FLAG_SENT; | |
290 | } | |
a6587818 | 291 | make_backups = save_make_backups; |
c57f4101 | 292 |