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