X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/8c2ffaf09553a85be1d2f7d135b959dbb8fa75c8..a8ed49583304181a0516ce98014ae7389ec4c160:/receiver.c diff --git a/receiver.c b/receiver.c index 565fa9d9..92a2cf31 100644 --- a/receiver.c +++ b/receiver.c @@ -21,6 +21,7 @@ #include "rsync.h" extern int verbose; +extern int what_has_changed; extern int delete_after; extern int csum_length; extern struct stats stats; @@ -56,29 +57,20 @@ extern struct filter_list_struct server_filter_list; * sending side. This is used by --delete-before and --delete-after. */ void delete_files(struct file_list *flist) { - struct file_list *dir_list; - char *argv[1], fbuf[MAXPATHLEN]; + char fbuf[MAXPATHLEN]; int j; - if (io_error && !(lp_ignore_errors(module_id) || ignore_errors)) { - rprintf(FINFO, - "IO error encountered -- skipping file deletion\n"); - return; - } - for (j = 0; j < flist->count; j++) { - if (!(flist->files[j]->flags & FLAG_DEL_START) - || !S_ISDIR(flist->files[j]->mode)) - continue; + struct file_struct *file = flist->files[j]; - argv[0] = f_name_to(flist->files[j], fbuf); - - if (!(dir_list = send_file_list(-1, 1, argv))) + if (!(file->flags & FLAG_DEL_HERE)) continue; - delete_missing(flist, dir_list, fbuf); + f_name_to(file, fbuf); + if (verbose > 1 && file->flags & FLAG_TOP_DIR) + rprintf(FINFO, "deleting in %s\n", safe_fname(fbuf)); - flist_free(dir_list); + delete_in_dir(flist, fbuf, file); } } @@ -132,7 +124,8 @@ static int get_tmpname(char *fnametmp, char *fname) maxname = MIN(MAXPATHLEN - 7 - length, NAME_MAX - 8); if (maxname < 1) { - rprintf(FERROR, "temporary filename too long: %s\n", fname); + rprintf(FERROR, "temporary filename too long: %s\n", + safe_fname(fname)); fnametmp[0] = '\0'; return 0; } @@ -236,7 +229,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r, if (flush_write_file(fd) < 0) goto report_write_error; -#if HAVE_FTRUNCATE +#ifdef HAVE_FTRUNCATE if (inplace && fd != -1) ftruncate(fd, offset); #endif @@ -265,6 +258,36 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r, } +static void read_gen_name(int fd, char *dirname, char *buf) +{ + int dlen; + int len = read_byte(fd); + + if (len & 0x80) { +#if MAXPATHLEN > 32767 + uchar lenbuf[2]; + read_buf(fd, (char *)lenbuf, 2); + len = (len & ~0x80) * 0x10000 + lenbuf[0] * 0x100 + lenbuf[1]; +#else + len = (len & ~0x80) * 0x100 + read_byte(fd); +#endif + } + + if (dirname) { + dlen = strlcpy(buf, dirname, MAXPATHLEN); + buf[dlen++] = '/'; + } else + dlen = 0; + + if (dlen + len >= MAXPATHLEN) { + rprintf(FERROR, "bogus data on generator name pipe\n"); + exit_cleanup(RERR_PROTOCOL); + } + + read_sbuf(fd, buf + dlen, len); +} + + static void discard_receive_data(int f_in, OFF_T length) { receive_data(f_in, NULL, -1, 0, NULL, -1, length); @@ -365,8 +388,8 @@ int recv_files(int f_in, struct file_list *flist, char *local_name, if (verbose > 2) rprintf(FINFO, "recv_files(%s)\n", safe_fname(fname)); - if (dry_run) { - if (!am_server && verbose) /* log the transfer */ + if (dry_run) { /* log the transfer */ + if (!am_server && verbose && !what_has_changed) rprintf(FINFO, "%s\n", safe_fname(fname)); continue; } @@ -404,6 +427,10 @@ int recv_files(int f_in, struct file_list *flist, char *local_name, case FNAMECMP_BACKUP: fnamecmp = get_backup_name(fname); break; + case FNAMECMP_FUZZY: + read_gen_name(f_in_name, file->dirname, fnamecmpbuf); + fnamecmp = fnamecmpbuf; + break; default: if (j >= basis_dir_cnt) { rprintf(FERROR, @@ -505,7 +532,8 @@ int recv_files(int f_in, struct file_list *flist, char *local_name, cleanup_set(fnametmp, partialptr, file, fd1, fd2); } - if (!am_server && verbose) /* log the transfer */ + /* log the transfer */ + if (!am_server && verbose && !what_has_changed) rprintf(FINFO, "%s\n", safe_fname(fname)); /* recv file data */ @@ -522,7 +550,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name, exit_cleanup(RERR_FILEIO); } - if ((recv_ok && !delay_updates) || inplace) { + if ((recv_ok && (!delay_updates || !partialptr)) || inplace) { finish_transfer(fname, fnametmp, file, recv_ok, 1); if (partialptr != fname && fnamecmp == partialptr) { do_unlink(partialptr); @@ -586,12 +614,14 @@ int recv_files(int f_in, struct file_list *flist, char *local_name, continue; if (verbose > 2) { rprintf(FINFO, "renaming %s to %s\n", - partialptr, fname); + safe_fname(partialptr), + safe_fname(fname)); } if (do_rename(partialptr, fname) < 0) { rsyserr(FERROR, errno, "rename failed for %s (from %s)", - fname, partialptr); + full_fname(fname), + safe_fname(partialptr)); } else { handle_partial_dir(partialptr, PDIR_DELETE);