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) { |
c5a8a208 WD |
41 | --- orig/main.c 2005-02-04 22:28:09 |
42 | +++ main.c 2005-02-05 01:24:16 | |
43 | @@ -32,12 +32,14 @@ extern int am_daemon; | |
44 | extern int verbose; | |
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; |
c5a8a208 | 58 | @@ -440,6 +442,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", | |
c5a8a208 | 71 | @@ -670,6 +678,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 WD |
79 | do_server_sender(f_in, f_out, argc, argv); |
80 | @@ -747,6 +757,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 | |
c5a8a208 | 90 | --- orig/options.c 2005-02-04 22:28:09 |
786384c2 | 91 | +++ options.c 2005-01-23 07:30:51 |
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; | |
c5a8a208 | 100 | @@ -92,6 +93,7 @@ int bwlimit = 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; |
c5a8a208 | 108 | @@ -286,6 +288,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"); |
c5a8a208 | 116 | @@ -360,6 +363,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 }, |
c5a8a208 | 124 | @@ -922,6 +926,9 @@ int parse_arguments(int *argc, const cha |
ac23c334 WD |
125 | else if (delete_mode || delete_excluded) |
126 | delete_mode = delete_before = 1; | |
c57f4101 | 127 | |
4945df2c WD |
128 | + if (delete_sent_files) |
129 | + need_messages_from_generator = 1; | |
c57f4101 | 130 | + |
4945df2c WD |
131 | *argv = poptGetArgs(pc); |
132 | *argc = count_args(*argv); | |
133 | ||
c5a8a208 | 134 | @@ -1318,6 +1325,9 @@ void server_options(char **args,int *arg |
2f2a7c3e WD |
135 | if (!implied_dirs && !am_sender) |
136 | args[ac++] = "--no-implied-dirs"; | |
7b675ff5 | 137 | |
c57f4101 WD |
138 | + if (delete_sent_files) |
139 | + args[ac++] = "--delete-sent-files"; | |
7b675ff5 | 140 | + |
c57f4101 WD |
141 | *argc = ac; |
142 | return; | |
7b675ff5 | 143 | |
d1cfcd41 | 144 | --- orig/receiver.c 2005-02-03 02:04:20 |
580f70f0 | 145 | +++ receiver.c 2004-08-13 08:38:51 |
d1cfcd41 | 146 | @@ -41,6 +41,7 @@ extern int basis_dir_cnt; |
b76d92e6 WD |
147 | extern int make_backups; |
148 | extern int do_progress; | |
f6c3b300 | 149 | extern int cleanup_got_literal; |
c57f4101 | 150 | +extern int delete_sent_files; |
f6c3b300 WD |
151 | extern int module_id; |
152 | extern int ignore_errors; | |
153 | extern int orig_umask; | |
d1cfcd41 | 154 | @@ -275,7 +276,7 @@ int recv_files(int f_in, struct file_lis |
c57f4101 WD |
155 | char *fname, fbuf[MAXPATHLEN]; |
156 | char template[MAXPATHLEN]; | |
157 | char fnametmp[MAXPATHLEN]; | |
afbebe13 WD |
158 | - char *fnamecmp, *partialptr; |
159 | + char *fnamecmp, *partialptr, numbuf[4]; | |
c57f4101 | 160 | char fnamecmpbuf[MAXPATHLEN]; |
8af144e1 | 161 | uchar *delayed_bits = NULL; |
7628f156 | 162 | struct file_struct *file; |
d1cfcd41 | 163 | @@ -532,7 +533,12 @@ int recv_files(int f_in, struct file_lis |
c57f4101 WD |
164 | |
165 | cleanup_disable(); | |
166 | ||
167 | - if (!recv_ok) { | |
168 | + if (recv_ok) { | |
169 | + if (delete_sent_files) { | |
170 | + SIVAL(numbuf, 0, i); | |
171 | + send_msg(MSG_SUCCESS, numbuf, 4); | |
172 | + } | |
173 | + } else { | |
8075fb75 WD |
174 | int msgtype = csum_length == SUM_LENGTH || read_batch ? |
175 | FERROR : FINFO; | |
176 | if (msgtype == FERROR || verbose) { | |
d1cfcd41 | 177 | @@ -556,9 +562,8 @@ int recv_files(int f_in, struct file_lis |
982426b8 | 178 | keptstr, redostr); |
8075fb75 WD |
179 | } |
180 | if (csum_length != SUM_LENGTH) { | |
c57f4101 | 181 | - char buf[4]; |
c57f4101 WD |
182 | - SIVAL(buf, 0, i); |
183 | - send_msg(MSG_REDO, buf, 4); | |
184 | + SIVAL(numbuf, 0, i); | |
185 | + send_msg(MSG_REDO, numbuf, 4); | |
186 | } | |
187 | } | |
188 | } | |
c5a8a208 | 189 | --- orig/rsync.h 2005-02-04 22:28:09 |
d1cfcd41 WD |
190 | +++ rsync.h 2005-02-03 02:04:59 |
191 | @@ -61,6 +61,7 @@ | |
c57f4101 WD |
192 | #define FLAG_HLINK_EOL (1<<1) /* generator only */ |
193 | #define FLAG_MOUNT_POINT (1<<2) /* sender only */ | |
d1cfcd41 | 194 | #define FLAG_DEL_HERE (1<<3) /* receiver/generator */ |
c57f4101 WD |
195 | +#define FLAG_SENT (1<<7) /* sender only */ |
196 | ||
197 | /* update this if you make incompatible changes */ | |
0b2fb126 | 198 | #define PROTOCOL_VERSION 29 |
c5a8a208 | 199 | @@ -142,6 +143,7 @@ enum logcode { FERROR=1, FINFO=2, FLOG=3 |
ea238f1c WD |
200 | /* Messages types that are sent over the message channel. The logcode |
201 | * values must all be present here with identical numbers. */ | |
202 | enum msgcode { | |
c57f4101 | 203 | + MSG_SUCCESS=6, /* successfully updated indicated flist index */ |
ea238f1c WD |
204 | MSG_DONE=5, /* current phase is done */ |
205 | MSG_REDO=4, /* reprocess indicated flist index */ | |
206 | MSG_ERROR=FERROR, MSG_INFO=FINFO, MSG_LOG=FLOG, /* remote logging */ | |
c5a8a208 | 207 | --- orig/rsync.yo 2005-02-05 01:23:49 |
d1cfcd41 WD |
208 | +++ rsync.yo 2005-02-03 02:05:29 |
209 | @@ -338,6 +338,7 @@ to the detailed description below for a | |
ac23c334 WD |
210 | --delete-during receiver deletes during xfer, not before |
211 | --delete-after receiver deletes after transfer, not before | |
786384c2 | 212 | --delete-excluded also delete excluded files on receiver |
c57f4101 WD |
213 | + --delete-sent-files updated/sent files are removed from sender |
214 | --ignore-errors delete even if there are I/O errors | |
786384c2 | 215 | --force force deletion of dirs even if not empty |
c57f4101 | 216 | --max-delete=NUM don't delete more than NUM files |
d1cfcd41 WD |
217 | @@ -727,6 +728,11 @@ receiving side that are not on the sendi |
218 | delete any files on the receiving side that are excluded (see bf(--exclude)). | |
219 | See bf(--delete) (which is implied) for more details on file-deletion. | |
7b675ff5 | 220 | |
c57f4101 WD |
221 | +dit(bf(--delete-sent-files)) This tells rsync to remove the source files |
222 | +on the sending side that are successfully transferred to the receiving | |
223 | +side. Directories are not removed, nor are files that are identical on | |
224 | +both systems. | |
7b675ff5 | 225 | + |
d1cfcd41 | 226 | dit(bf(--ignore-errors)) Tells bf(--delete) to go ahead and delete files |
c57f4101 | 227 | even when there are I/O errors. |
7b675ff5 | 228 | |
d1cfcd41 | 229 | --- orig/sender.c 2005-02-03 02:04:20 |
982426b8 | 230 | +++ sender.c 2004-07-26 16:49:19 |
f6c3b300 WD |
231 | @@ -26,6 +26,7 @@ extern int io_error; |
232 | extern int dry_run; | |
c57f4101 WD |
233 | extern int am_server; |
234 | extern int am_daemon; | |
c57f4101 | 235 | +extern int delete_sent_files; |
f6c3b300 | 236 | extern int protocol_version; |
0b2fb126 | 237 | extern int updating_basis_file; |
a6587818 | 238 | extern int make_backups; |
0b2fb126 | 239 | @@ -94,7 +95,29 @@ static struct sum_struct *receive_sums(i |
c57f4101 WD |
240 | return s; |
241 | } | |
242 | ||
243 | +static struct file_list *the_flist; | |
244 | ||
245 | +void successful_send(int i) | |
246 | +{ | |
247 | + char fname[MAXPATHLEN]; | |
248 | + struct file_struct *file; | |
249 | + unsigned int offset; | |
250 | + | |
4945df2c | 251 | + if (!the_flist || i < 0 || i >= the_flist->count) |
c57f4101 WD |
252 | + return; |
253 | + | |
254 | + file = the_flist->files[i]; | |
255 | + if (!(file->flags & FLAG_SENT)) | |
256 | + return; /* We didn't send it -- impossible! */ | |
257 | + if (file->basedir) { | |
258 | + offset = stringjoin(fname, sizeof fname, | |
259 | + file->basedir, "/", NULL); | |
260 | + } else | |
261 | + offset = 0; | |
262 | + f_name_to(file, fname + offset); | |
263 | + if (delete_sent_files && do_unlink(fname) == 0 && verbose > 0) | |
264 | + rprintf(FINFO, "sender removed %s\n", fname + offset); | |
265 | +} | |
266 | ||
267 | void send_files(struct file_list *flist, int f_out, int f_in) | |
268 | { | |
0b2fb126 | 269 | @@ -113,6 +136,8 @@ void send_files(struct file_list *flist, |
c57f4101 WD |
270 | if (verbose > 2) |
271 | rprintf(FINFO, "send_files starting\n"); | |
272 | ||
273 | + the_flist = flist; | |
274 | + | |
275 | while (1) { | |
276 | unsigned int offset; | |
277 | ||
d1cfcd41 | 278 | @@ -254,6 +279,9 @@ void send_files(struct file_list *flist, |
982426b8 WD |
279 | rprintf(FINFO, "sender finished %s\n", |
280 | safe_fname(fname)); | |
281 | } | |
c57f4101 WD |
282 | + |
283 | + /* Flag that we actually sent this entry. */ | |
284 | + file->flags |= FLAG_SENT; | |
285 | } | |
a6587818 | 286 | make_backups = save_make_backups; |
c57f4101 | 287 |