#include "rsync.h"
extern int verbose;
-extern int recurse;
extern int delete_after;
extern int csum_length;
extern struct stats stats;
int j;
for (j = 0; j < flist->count; j++) {
- if (!(flist->files[j]->flags & FLAG_DEL_START)
- || !S_ISDIR(flist->files[j]->mode))
+ struct file_struct *file = flist->files[j];
+
+ if (!(file->flags & FLAG_DEL_HERE))
continue;
- delete_in_dir(flist, f_name_to(flist->files[j], fbuf));
+ f_name_to(file, fbuf);
+ if (verbose > 1 && file->flags & FLAG_TOP_DIR)
+ rprintf(FINFO, "deleting in %s\n", safe_fname(fbuf));
+
+ delete_in_dir(flist, fbuf, file);
}
}
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;
}
if (flush_write_file(fd) < 0)
goto report_write_error;
-#if HAVE_FTRUNCATE
+#ifdef HAVE_FTRUNCATE
if (inplace && fd != -1)
ftruncate(fd, offset);
#endif
}
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 */
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)
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) {
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);
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);
}
}
- if (delete_after && recurse && !local_name && flist->count > 0)
+ if (delete_after && !local_name && flist->count > 0)
delete_files(flist);
if (verbose > 2)