X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/48e1c8c69d9af33fb11f849901150bd4f2ac3eb4..8c2ffaf09553a85be1d2f7d135b959dbb8fa75c8:/receiver.c diff --git a/receiver.c b/receiver.c index 3acb7bd0..565fa9d9 100644 --- a/receiver.c +++ b/receiver.c @@ -21,7 +21,6 @@ #include "rsync.h" extern int verbose; -extern int recurse; extern int delete_after; extern int csum_length; extern struct stats stats; @@ -57,15 +56,29 @@ 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) { - char fbuf[MAXPATHLEN]; + struct file_list *dir_list; + char *argv[1], 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; - delete_in_dir(flist, f_name_to(flist->files[j], fbuf)); + argv[0] = f_name_to(flist->files[j], fbuf); + + if (!(dir_list = send_file_list(-1, 1, argv))) + continue; + + delete_missing(flist, dir_list, fbuf); + + flist_free(dir_list); } } @@ -223,7 +236,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; -#ifdef HAVE_FTRUNCATE +#if HAVE_FTRUNCATE if (inplace && fd != -1) ftruncate(fd, offset); #endif @@ -289,7 +302,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name, if (delay_updates) { int sz = (flist->count + 7) / 8; - if (!(delayed_bits = new_array(char, sz))) + if (!(delayed_bits = new_array(uchar, sz))) out_of_memory("recv_files"); memset(delayed_bits, 0, sz); } @@ -330,16 +343,27 @@ int recv_files(int f_in, struct file_list *flist, char *local_name, } file = flist->files[i]; + if (S_ISDIR(file->mode)) { + rprintf(FERROR, "[%s] got index of directory: %d\n", + who_am_i(), i); + exit_cleanup(RERR_PROTOCOL); + } stats.current_file_index = i; stats.num_transferred_files++; stats.total_transferred_size += file->length; cleanup_got_literal = 0; - if (local_name) - fname = local_name; - else - fname = f_name_to(file, fbuf); + fname = local_name ? local_name : f_name_to(file, fbuf); + + if (server_filter_list.head + && check_filter(&server_filter_list, fname, 0) < 0) { + rprintf(FERROR, "attempt to hack rsync failed.\n"); + exit_cleanup(RERR_PROTOCOL); + } + + if (verbose > 2) + rprintf(FINFO, "recv_files(%s)\n", safe_fname(fname)); if (dry_run) { if (!am_server && verbose) /* log the transfer */ @@ -349,9 +373,6 @@ int recv_files(int f_in, struct file_list *flist, char *local_name, initial_stats = stats; - if (verbose > 2) - rprintf(FINFO, "recv_files(%s)\n", safe_fname(fname)); - if (read_batch) { while (i > next_gen_i) { if (f_in_name >= 0 && next_gen_i >= 0) @@ -369,13 +390,6 @@ int recv_files(int f_in, struct file_list *flist, char *local_name, next_gen_i = -1; } - if (server_filter_list.head - && check_filter(&server_filter_list, fname, - S_ISDIR(file->mode)) < 0) { - rprintf(FERROR, "attempt to hack rsync failed.\n"); - exit_cleanup(RERR_PROTOCOL); - } - partialptr = partial_dir ? partial_dir_fname(fname) : fname; if (f_in_name >= 0) { @@ -586,7 +600,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name, } } - if (delete_after && recurse && !local_name && flist->count > 0) + if (delete_after && !local_name && flist->count > 0) delete_files(flist); if (verbose > 2)