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