If the generator sends us the index of a directory, generate an
[rsync/rsync.git] / receiver.c
CommitLineData
e327acec 1/* -*- c-file-style: "linux" -*-
17fadf7d 2
e327acec 3 Copyright (C) 1996-2000 by Andrew Tridgell
2f03f956 4 Copyright (C) Paul Mackerras 1996
17fadf7d 5
2f03f956
AT
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
17fadf7d 10
2f03f956
AT
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
17fadf7d 15
2f03f956
AT
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#include "rsync.h"
22
23extern int verbose;
92b9eb97 24extern int delete_after;
2f03f956
AT
25extern int csum_length;
26extern struct stats stats;
27extern int dry_run;
16cc9ca2
WD
28extern int read_batch;
29extern int batch_gen_fd;
2f03f956 30extern int am_server;
41cfde6b 31extern int protocol_version;
2f03f956 32extern int relative_paths;
566fce32 33extern int keep_dirlinks;
2f03f956 34extern int preserve_hard_links;
92b9eb97 35extern int preserve_perms;
2f03f956
AT
36extern int io_error;
37extern char *tmpdir;
a7260c40 38extern char *partial_dir;
ee297522 39extern char *basis_dir[];
c56595d7 40extern int basis_dir_cnt;
53dd3135 41extern int make_backups;
16417f8b 42extern int do_progress;
925c517f 43extern int cleanup_got_literal;
92b9eb97
WD
44extern int module_id;
45extern int ignore_errors;
46extern int orig_umask;
55e50d89 47extern int keep_partial;
ba582f75 48extern int checksum_seed;
a3221d2a 49extern int inplace;
48e1c8c6 50extern int delay_updates;
2f03f956 51
7842418b 52extern struct filter_list_struct server_filter_list;
5ebab6c1
WD
53
54
3ab56a20
WD
55/* This deletes any files on the receiving side that are not present on the
56 * sending side. This is used by --delete-before and --delete-after. */
6957ae33 57void delete_files(struct file_list *flist)
2f03f956 58{
2430e984 59 struct file_list *dir_list;
462c51d9 60 char *argv[1], fbuf[MAXPATHLEN];
3ab56a20 61 int j;
2f03f956 62
462c51d9
WD
63 if (io_error && !(lp_ignore_errors(module_id) || ignore_errors)) {
64 rprintf(FINFO,
4ccfd96c 65 "IO error encountered -- skipping file deletion\n");
462c51d9
WD
66 return;
67 }
68
1e82e2ce 69 for (j = 0; j < flist->count; j++) {
71e27c46 70 if (!(flist->files[j]->flags & FLAG_DEL_START)
a5342644
WD
71 || !S_ISDIR(flist->files[j]->mode))
72 continue;
2f03f956 73
2430e984 74 argv[0] = f_name_to(flist->files[j], fbuf);
462c51d9
WD
75
76 if (!(dir_list = send_file_list(-1, 1, argv)))
77 continue;
2430e984
WD
78
79 delete_missing(flist, dir_list, fbuf);
80
81 flist_free(dir_list);
2f03f956
AT
82 }
83}
84
85
52d3e106
S
86/*
87 * get_tmpname() - create a tmp filename for a given filename
88 *
89 * If a tmpdir is defined, use that as the directory to
90 * put it in. Otherwise, the tmp filename is in the same
91 * directory as the given name. Note that there may be no
92 * directory at all in the given name!
17fadf7d 93 *
52d3e106
S
94 * The tmp filename is basically the given filename with a
95 * dot prepended, and .XXXXXX appended (for mkstemp() to
96 * put its unique gunk in). Take care to not exceed
97 * either the MAXPATHLEN or NAME_MAX, esp. the last, as
98 * the basename basically becomes 8 chars longer. In that
99 * case, the original name is shortened sufficiently to
100 * make it all fit.
17fadf7d 101 *
52d3e106
S
102 * Of course, there's no real reason for the tmp name to
103 * look like the original, except to satisfy us humans.
104 * As long as it's unique, rsync will work.
105 */
106
2f03f956
AT
107static int get_tmpname(char *fnametmp, char *fname)
108{
109 char *f;
52d3e106
S
110 int length = 0;
111 int maxname;
2f03f956 112
2f03f956 113 if (tmpdir) {
a24639bb 114 /* Note: this can't overflow, so the return value is safe */
b7cee949 115 length = strlcpy(fnametmp, tmpdir, MAXPATHLEN - 2);
52d3e106
S
116 fnametmp[length++] = '/';
117 fnametmp[length] = '\0'; /* always NULL terminated */
0c2ef5f4 118 }
52d3e106 119
0c2ef5f4 120 if ((f = strrchr(fname, '/')) != NULL) {
52d3e106
S
121 ++f;
122 if (!tmpdir) {
123 length = f - fname;
0c2ef5f4 124 /* copy up to and including the slash */
52d3e106 125 strlcpy(fnametmp, fname, length + 1);
0c2ef5f4 126 }
446e239e 127 } else
52d3e106 128 f = fname;
52d3e106
S
129 fnametmp[length++] = '.';
130 fnametmp[length] = '\0'; /* always NULL terminated */
2f03f956 131
52d3e106 132 maxname = MIN(MAXPATHLEN - 7 - length, NAME_MAX - 8);
2f03f956 133
0c2ef5f4 134 if (maxname < 1) {
52d3e106
S
135 rprintf(FERROR, "temporary filename too long: %s\n", fname);
136 fnametmp[0] = '\0';
2f03f956
AT
137 return 0;
138 }
139
17fadf7d 140 strlcpy(fnametmp + length, f, maxname);
52d3e106 141 strcat(fnametmp + length, ".XXXXXX");
2f03f956
AT
142
143 return 1;
144}
145
146
7e5fa372
WD
147static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
148 char *fname, int fd, OFF_T total_size)
2f03f956 149{
7e5fa372
WD
150 static char file_sum1[MD4_SUM_LENGTH];
151 static char file_sum2[MD4_SUM_LENGTH];
152 struct map_struct *mapbuf;
fc0257c9 153 struct sum_struct sum;
6c495e0d 154 int32 len;
2f03f956 155 OFF_T offset = 0;
89e540e6 156 OFF_T offset2;
2f03f956 157 char *data;
6c495e0d 158 int32 i;
e1f67417 159 char *map = NULL;
17fadf7d 160
fc0257c9 161 read_sum_head(f_in, &sum);
17fadf7d 162
7e5fa372 163 if (fd_r >= 0 && size_r > 0) {
80264051
WD
164 int32 read_size = MAX(sum.blength * 2, 16*1024);
165 mapbuf = map_file(fd_r, size_r, read_size, sum.blength);
7e5fa372
WD
166 if (verbose > 2) {
167 rprintf(FINFO, "recv mapped %s of size %.0f\n",
ecc81fce 168 safe_fname(fname_r), (double)size_r);
7e5fa372
WD
169 }
170 } else
171 mapbuf = NULL;
172
ba582f75 173 sum_init(checksum_seed);
17fadf7d 174
3f55bd5d 175 while ((i = recv_token(f_in, &data)) != 0) {
16417f8b
WD
176 if (do_progress)
177 show_progress(offset, total_size);
2f03f956
AT
178
179 if (i > 0) {
2f03f956 180 if (verbose > 3) {
5f808dfb
AT
181 rprintf(FINFO,"data recv %d at %.0f\n",
182 i,(double)offset);
2f03f956
AT
183 }
184
185 stats.literal_data += i;
186 cleanup_got_literal = 1;
17fadf7d 187
6c495e0d 188 sum_update(data, i);
2f03f956 189
c52461f9
WD
190 if (fd != -1 && write_file(fd,data,i) != i)
191 goto report_write_error;
2f03f956
AT
192 offset += i;
193 continue;
17fadf7d 194 }
2f03f956
AT
195
196 i = -(i+1);
6c495e0d 197 offset2 = i * (OFF_T)sum.blength;
fc0257c9 198 len = sum.blength;
d2a918b4 199 if (i == (int)sum.count-1 && sum.remainder != 0)
fc0257c9 200 len = sum.remainder;
17fadf7d 201
2f03f956 202 stats.matched_data += len;
17fadf7d 203
6c495e0d
WD
204 if (verbose > 3) {
205 rprintf(FINFO,
206 "chunk[%d] of size %ld at %.0f offset=%.0f\n",
207 i, (long)len, (double)offset2, (double)offset);
208 }
17fadf7d 209
446e239e
WD
210 if (mapbuf) {
211 map = map_ptr(mapbuf,offset2,len);
17fadf7d 212
c55f7021 213 see_token(map, len);
6c495e0d 214 sum_update(map, len);
c55f7021 215 }
17fadf7d 216
fab65a5b 217 if (inplace) {
89e540e6 218 if (offset == offset2 && fd != -1) {
c52461f9
WD
219 if (flush_write_file(fd) < 0)
220 goto report_write_error;
89e540e6
WD
221 offset += len;
222 if (do_lseek(fd, len, SEEK_CUR) != offset) {
fab65a5b
WD
223 rsyserr(FERROR, errno,
224 "lseek failed on %s",
225 full_fname(fname));
226 exit_cleanup(RERR_FILEIO);
227 }
89e540e6 228 continue;
a3221d2a 229 }
2f03f956 230 }
c52461f9
WD
231 if (fd != -1 && write_file(fd, map, len) != (int)len)
232 goto report_write_error;
2f03f956
AT
233 offset += len;
234 }
235
85f14172
WD
236 if (flush_write_file(fd) < 0)
237 goto report_write_error;
76c21947 238
25ff0441 239#if HAVE_FTRUNCATE
fab65a5b 240 if (inplace && fd != -1)
a3221d2a
WD
241 ftruncate(fd, offset);
242#endif
243
16417f8b
WD
244 if (do_progress)
245 end_progress(total_size);
2f03f956
AT
246
247 if (fd != -1 && offset > 0 && sparse_end(fd) != 0) {
c52461f9 248 report_write_error:
d62bcc17
WD
249 rsyserr(FERROR, errno, "write failed on %s",
250 full_fname(fname));
65417579 251 exit_cleanup(RERR_FILEIO);
2f03f956
AT
252 }
253
254 sum_end(file_sum1);
255
7e5fa372
WD
256 if (mapbuf)
257 unmap_file(mapbuf);
258
bc63ae3f 259 read_buf(f_in,file_sum2,MD4_SUM_LENGTH);
d2a918b4 260 if (verbose > 2)
bc63ae3f 261 rprintf(FINFO,"got file_sum\n");
d2a918b4 262 if (fd != -1 && memcmp(file_sum1, file_sum2, MD4_SUM_LENGTH) != 0)
bc63ae3f 263 return 0;
2f03f956
AT
264 return 1;
265}
266
267
8ed9d849
WD
268static void discard_receive_data(int f_in, OFF_T length)
269{
7e5fa372 270 receive_data(f_in, NULL, -1, 0, NULL, -1, length);
8ed9d849
WD
271}
272
273
b35d0d8e
MP
274/**
275 * main routine for receiver process.
276 *
277 * Receiver process runs on the same host as the generator process. */
41cfde6b
WD
278int recv_files(int f_in, struct file_list *flist, char *local_name,
279 int f_in_name)
17fadf7d 280{
16cc9ca2 281 int next_gen_i = -1;
2f03f956
AT
282 int fd1,fd2;
283 STRUCT_STAT st;
446e239e 284 char *fname, fbuf[MAXPATHLEN];
f62c17e3 285 char template[MAXPATHLEN];
2f03f956 286 char fnametmp[MAXPATHLEN];
a7260c40 287 char *fnamecmp, *partialptr;
375a4556 288 char fnamecmpbuf[MAXPATHLEN];
48e1c8c6 289 uchar *delayed_bits = NULL;
2f03f956 290 struct file_struct *file;
1b7c47cb 291 struct stats initial_stats;
4e834af1
WD
292 int save_make_backups = make_backups;
293 int i, recv_ok, phase = 0;
11a5a3c7 294
d2a918b4 295 if (verbose > 2)
2f03f956 296 rprintf(FINFO,"recv_files(%d) starting\n",flist->count);
2f03f956 297
cb869c26 298 if (flist->hlink_pool) {
9935066b
S
299 pool_destroy(flist->hlink_pool);
300 flist->hlink_pool = NULL;
301 }
302
48e1c8c6
WD
303 if (delay_updates) {
304 int sz = (flist->count + 7) / 8;
dc3afaf6 305 if (!(delayed_bits = new_array(uchar, sz)))
48e1c8c6
WD
306 out_of_memory("recv_files");
307 memset(delayed_bits, 0, sz);
308 }
309
17fadf7d 310 while (1) {
2f03f956
AT
311 cleanup_disable();
312
313 i = read_int(f_in);
314 if (i == -1) {
16cc9ca2 315 if (read_batch) {
41cfde6b
WD
316 if (next_gen_i != flist->count) {
317 do {
318 if (f_in_name >= 0
319 && next_gen_i >= 0)
320 read_byte(f_in_name);
321 } while (read_int(batch_gen_fd) != -1);
322 }
16cc9ca2
WD
323 next_gen_i = -1;
324 }
325
4e834af1
WD
326 if (phase)
327 break;
5ebab6c1 328
4e834af1
WD
329 phase = 1;
330 csum_length = SUM_LENGTH;
331 if (verbose > 2)
332 rprintf(FINFO, "recv_files phase=%d\n", phase);
333 send_msg(MSG_DONE, "", 0);
aec6b9f8 334 if (keep_partial && !partial_dir)
4e834af1
WD
335 make_backups = 0; /* prevents double backup */
336 continue;
2f03f956
AT
337 }
338
339 if (i < 0 || i >= flist->count) {
17fadf7d 340 rprintf(FERROR,"Invalid file index %d in recv_files (count=%d)\n",
2f03f956 341 i, flist->count);
65417579 342 exit_cleanup(RERR_PROTOCOL);
2f03f956
AT
343 }
344
345 file = flist->files[i];
2f03f956 346
97feb557 347 stats.current_file_index = i;
2f03f956
AT
348 stats.num_transferred_files++;
349 stats.total_transferred_size += file->length;
925c517f 350 cleanup_got_literal = 0;
2f03f956
AT
351
352 if (local_name)
353 fname = local_name;
446e239e 354 else
3fef5364 355 fname = f_name_to(file, fbuf);
2f03f956
AT
356
357 if (dry_run) {
ecc81fce
WD
358 if (!am_server && verbose) /* log the transfer */
359 rprintf(FINFO, "%s\n", safe_fname(fname));
2f03f956
AT
360 continue;
361 }
362
1b7c47cb
AT
363 initial_stats = stats;
364
2f03f956 365 if (verbose > 2)
ecc81fce 366 rprintf(FINFO, "recv_files(%s)\n", safe_fname(fname));
2f03f956 367
16cc9ca2
WD
368 if (read_batch) {
369 while (i > next_gen_i) {
41cfde6b
WD
370 if (f_in_name >= 0 && next_gen_i >= 0)
371 read_byte(f_in_name);
16cc9ca2
WD
372 next_gen_i = read_int(batch_gen_fd);
373 if (next_gen_i == -1)
374 next_gen_i = flist->count;
375 }
376 if (i < next_gen_i) {
377 rprintf(FINFO, "skipping update for \"%s\"\n",
ecc81fce 378 safe_fname(fname));
16cc9ca2
WD
379 discard_receive_data(f_in, file->length);
380 continue;
381 }
41cfde6b 382 next_gen_i = -1;
16cc9ca2
WD
383 }
384
7842418b
WD
385 if (server_filter_list.head
386 && check_filter(&server_filter_list, fname,
5ebab6c1 387 S_ISDIR(file->mode)) < 0) {
33eff8bf
WD
388 rprintf(FERROR, "attempt to hack rsync failed.\n");
389 exit_cleanup(RERR_PROTOCOL);
5ebab6c1
WD
390 }
391
41cfde6b
WD
392 partialptr = partial_dir ? partial_dir_fname(fname) : fname;
393
394 if (f_in_name >= 0) {
ee297522
WD
395 uchar j;
396 switch (j = read_byte(f_in_name)) {
41cfde6b 397 case FNAMECMP_FNAME:
a7260c40 398 fnamecmp = fname;
41cfde6b
WD
399 break;
400 case FNAMECMP_PARTIAL_DIR:
401 fnamecmp = partialptr ? partialptr : fname;
402 break;
403 case FNAMECMP_BACKUP:
404 fnamecmp = get_backup_name(fname);
405 break;
41cfde6b 406 default:
c56595d7
WD
407 if (j >= basis_dir_cnt) {
408 rprintf(FERROR,
409 "invalid basis_dir index: %d.\n",
410 j);
411 exit_cleanup(RERR_PROTOCOL);
412 }
41cfde6b 413 pathjoin(fnamecmpbuf, sizeof fnamecmpbuf,
ee297522 414 basis_dir[j], fname);
41cfde6b
WD
415 fnamecmp = fnamecmpbuf;
416 break;
417 }
a7260c40 418 } else
41cfde6b 419 fnamecmp = fname;
dc55d7bd 420
17fadf7d 421 /* open the file */
8c9fd200 422 fd1 = do_open(fnamecmp, O_RDONLY, 0);
375a4556 423
2f03f956 424 if (fd1 != -1 && do_fstat(fd1,&st) != 0) {
d62bcc17
WD
425 rsyserr(FERROR, errno, "fstat %s failed",
426 full_fname(fnamecmp));
8ed9d849 427 discard_receive_data(f_in, file->length);
2f03f956
AT
428 close(fd1);
429 continue;
430 }
431
350e4e4d
S
432 if (fd1 != -1 && S_ISDIR(st.st_mode) && fnamecmp == fname) {
433 /* this special handling for directories
434 * wouldn't be necessary if robust_rename()
435 * and the underlying robust_unlink could cope
436 * with directories
437 */
ea42541f
WD
438 rprintf(FERROR,"recv_files: %s is a directory\n",
439 full_fname(fnamecmp));
8ed9d849 440 discard_receive_data(f_in, file->length);
2f03f956
AT
441 close(fd1);
442 continue;
443 }
444
350e4e4d
S
445 if (fd1 != -1 && !S_ISREG(st.st_mode)) {
446 close(fd1);
447 fd1 = -1;
350e4e4d
S
448 }
449
4df9f368 450 if (fd1 != -1 && !preserve_perms) {
85ed0aa3 451 /* if the file exists already and we aren't preserving
17fadf7d
WD
452 * permissions then act as though the remote end sent
453 * us the file permissions we already have */
4df9f368
AT
454 file->mode = st.st_mode;
455 }
456
a3221d2a
WD
457 /* We now check to see if we are writing file "inplace" */
458 if (inplace) {
dc55d7bd 459 fd2 = do_open(fname, O_WRONLY|O_CREAT, 0);
a3221d2a
WD
460 if (fd2 == -1) {
461 rsyserr(FERROR, errno, "open %s failed",
dc55d7bd 462 full_fname(fname));
8ed9d849 463 discard_receive_data(f_in, file->length);
a3221d2a
WD
464 if (fd1 != -1)
465 close(fd1);
466 continue;
467 }
468 } else {
469 if (!get_tmpname(fnametmp,fname)) {
8ed9d849 470 discard_receive_data(f_in, file->length);
a3221d2a
WD
471 if (fd1 != -1)
472 close(fd1);
473 continue;
474 }
475
476 strlcpy(template, fnametmp, sizeof template);
2f03f956 477
a3221d2a
WD
478 /* we initially set the perms without the
479 * setuid/setgid bits to ensure that there is no race
480 * condition. They are then correctly updated after
481 * the lchown. Thanks to snabb@epipe.fi for pointing
482 * this out. We also set it initially without group
483 * access because of a similar race condition. */
f62c17e3 484 fd2 = do_mkstemp(fnametmp, file->mode & INITACCESSPERMS);
17fadf7d 485
a3221d2a
WD
486 /* in most cases parent directories will already exist
487 * because their information should have been previously
488 * transferred, but that may not be the case with -R */
489 if (fd2 == -1 && relative_paths && errno == ENOENT
490 && create_directory_path(fnametmp, orig_umask) == 0) {
491 strlcpy(fnametmp, template, sizeof fnametmp);
492 fd2 = do_mkstemp(fnametmp, file->mode & INITACCESSPERMS);
493 }
494 if (fd2 == -1) {
495 rsyserr(FERROR, errno, "mkstemp %s failed",
496 full_fname(fnametmp));
8ed9d849 497 discard_receive_data(f_in, file->length);
a3221d2a
WD
498 if (fd1 != -1)
499 close(fd1);
500 continue;
501 }
502
a7260c40
WD
503 if (partialptr)
504 cleanup_set(fnametmp, partialptr, file, fd1, fd2);
a3221d2a 505 }
2f03f956 506
ecc81fce
WD
507 if (!am_server && verbose) /* log the transfer */
508 rprintf(FINFO, "%s\n", safe_fname(fname));
11a5a3c7 509
2f03f956 510 /* recv file data */
7e5fa372
WD
511 recv_ok = receive_data(f_in, fnamecmp, fd1, st.st_size,
512 fname, fd2, file->length);
1b7c47cb
AT
513
514 log_recv(file, &initial_stats);
17fadf7d 515
d2a918b4 516 if (fd1 != -1)
2f03f956 517 close(fd1);
9f27cd8c 518 if (close(fd2) < 0) {
d62bcc17
WD
519 rsyserr(FERROR, errno, "close failed on %s",
520 full_fname(fnametmp));
9f27cd8c
WD
521 exit_cleanup(RERR_FILEIO);
522 }
17fadf7d 523
48e1c8c6 524 if ((recv_ok && !delay_updates) || inplace) {
aec6b9f8
WD
525 finish_transfer(fname, fnametmp, file, recv_ok, 1);
526 if (partialptr != fname && fnamecmp == partialptr) {
527 do_unlink(partialptr);
528 handle_partial_dir(partialptr, PDIR_DELETE);
529 }
530 } else if (keep_partial && partialptr
531 && handle_partial_dir(partialptr, PDIR_CREATE)) {
532 finish_transfer(partialptr, fnametmp, file, recv_ok,
533 !partial_dir);
48e1c8c6
WD
534 if (delay_updates && recv_ok)
535 delayed_bits[i/8] |= 1 << (i % 8);
aec6b9f8 536 } else {
a7260c40 537 partialptr = NULL;
55e50d89 538 do_unlink(fnametmp);
a7260c40
WD
539 }
540
2f03f956 541 cleanup_disable();
554e0a8d 542
2f03f956 543 if (!recv_ok) {
007e3c0e
WD
544 int msgtype = csum_length == SUM_LENGTH || read_batch ?
545 FERROR : FINFO;
546 if (msgtype == FERROR || verbose) {
a7260c40
WD
547 char *errstr, *redostr, *keptstr;
548 if (!(keep_partial && partialptr) && !inplace)
549 keptstr = "discarded";
550 else if (partial_dir)
551 keptstr = "put into partial-dir";
552 else
553 keptstr = "retained";
007e3c0e
WD
554 if (msgtype == FERROR) {
555 errstr = "ERROR";
556 redostr = "";
557 } else {
558 errstr = "WARNING";
559 redostr = " (will try again)";
560 }
561 rprintf(msgtype,
a7260c40 562 "%s: %s failed verification -- update %s%s.\n",
ecc81fce
WD
563 errstr, safe_fname(fname),
564 keptstr, redostr);
007e3c0e 565 }
e2bc4126 566 if (csum_length != SUM_LENGTH) {
0569a133 567 char buf[4];
0569a133
WD
568 SIVAL(buf, 0, i);
569 send_msg(MSG_REDO, buf, 4);
2f03f956
AT
570 }
571 }
572 }
4e834af1 573 make_backups = save_make_backups;
2f03f956 574
48e1c8c6
WD
575 if (delay_updates) {
576 for (i = 0; i < flist->count; i++) {
577 struct file_struct *file = flist->files[i];
578 if (!file->basename
579 || !(delayed_bits[i/8] & (1 << (i % 8))))
580 continue;
581 fname = local_name ? local_name : f_name(file);
582 partialptr = partial_dir_fname(fname);
583 if (partialptr) {
584 if (make_backups && !make_backup(fname))
585 continue;
586 if (verbose > 2) {
587 rprintf(FINFO, "renaming %s to %s\n",
588 partialptr, fname);
589 }
590 if (do_rename(partialptr, fname) < 0) {
591 rsyserr(FERROR, errno,
592 "rename failed for %s (from %s)",
593 fname, partialptr);
594 } else {
595 handle_partial_dir(partialptr,
596 PDIR_DELETE);
597 }
598 }
599 }
600 }
601
2430e984 602 if (delete_after && !local_name && flist->count > 0)
3f55bd5d 603 delete_files(flist);
57df171b 604
2f03f956
AT
605 if (verbose > 2)
606 rprintf(FINFO,"recv_files finished\n");
17fadf7d 607
2f03f956
AT
608 return 0;
609}