extern int am_root;
extern int am_server;
extern int am_daemon;
-extern int incremental;
+extern int inc_recurse;
extern int do_progress;
extern int relative_paths;
extern int implied_dirs;
dry_run = 0;
if (!get_tmpname(fnametmp, "deldelay")
|| (deldelay_fd = do_mkstemp(fnametmp, 0600)) < 0) {
- rprintf(FINFO, "NOTE: Unable to create delete-delay temp file--"
- "switching to --delete-after.\n");
+ rprintf(FINFO, "NOTE: Unable to create delete-delay temp file%s.\n",
+ inc_recurse ? "" : " -- switching to --delete-after");
delete_during = 0;
- delete_after = 1;
+ delete_after = !inc_recurse;
dry_run = save_dry_run;
return 0;
}
|| stdout_format_has_i > 1 || (xname && *xname)) && !read_batch) {
if (protocol_version >= 29) {
if (ndx >= 0)
- write_int(sock_f_out, ndx + cur_flist->ndx_start);
+ write_ndx(sock_f_out, ndx + cur_flist->ndx_start);
write_shortint(sock_f_out, iflags);
if (iflags & ITEM_BASIS_TYPE_FOLLOWS)
write_byte(sock_f_out, fnamecmp_type);
rprintf(code, "%s/\n", fname);
if (real_ret != 0 && one_file_system)
real_st.st_dev = filesystem_dev;
- if (incremental) {
+ if (inc_recurse) {
if (one_file_system) {
uint32 *devp = F_DIRDEV_P(file);
DEV_MAJOR(devp) = major(real_st.st_dev);
notify_others:
if (remove_source_files && !delay_updates && !phase)
increment_active_files(ndx, itemizing, code);
- if (incremental && !dry_run)
+ if (inc_recurse && !dry_run)
cur_flist->in_progress++;
#ifdef SUPPORT_HARD_LINKS
if (preserve_hard_links && F_IS_HLINKED(file))
file->flags |= FLAG_FILE_SENT;
#endif
- write_int(f_out, ndx + cur_flist->ndx_start);
+ write_ndx(f_out, ndx + cur_flist->ndx_start);
if (itemizing) {
int iflags = ITEM_TRANSFER;
if (always_checksum > 0)
close(fd);
}
+static void touch_up_dirs(struct file_list *flist, int ndx,
+ int need_retouch_dir_times, int lull_mod)
+{
+ struct file_struct *file;
+ char *fname;
+ int i, j, start, end;
+
+ if (ndx < 0) {
+ start = 0;
+ end = flist->count - 1;
+ } else
+ start = end = ndx;
+
+ /* Fix any directory permissions that were modified during the
+ * transfer and/or re-set any tweaked modified-time values. */
+ for (i = start, j = 0; i <= end; i++) {
+ file = flist->files[i];
+ if (!F_IS_ACTIVE(file) || !S_ISDIR(file->mode)
+ || file->flags & FLAG_MISSING_DIR)
+ continue;
+ if (!need_retouch_dir_times && file->mode & S_IWUSR)
+ continue;
+ fname = f_name(file, NULL);
+ if (!(file->mode & S_IWUSR))
+ do_chmod(fname, file->mode);
+ if (need_retouch_dir_times)
+ set_modtime(fname, file->modtime, file->mode);
+ if (allowed_lull && !(++j % lull_mod))
+ maybe_send_keepalive();
+ else if (!(j % 200))
+ maybe_flush_socket();
+ }
+}
+
void generate_files(int f_out, char *local_name)
{
int i;
ignore_timeout = 1;
do {
- if (incremental && delete_during && cur_flist->ndx_start) {
+ if (inc_recurse && delete_during && cur_flist->ndx_start) {
struct file_struct *fp = dir_flist->files[cur_flist->parent_ndx];
if (BITS_SETnUNSET(fp->flags, FLAG_XFER_DIR, FLAG_MISSING_DIR)) {
dev_t dirdev;
maybe_flush_socket();
}
- if (!incremental) {
+ if (!inc_recurse) {
if (delete_during)
delete_in_dir(NULL, NULL, NULL, &dev_zero);
phase++;
phase);
}
- write_int(f_out, NDX_DONE);
+ write_ndx(f_out, NDX_DONE);
}
csum_length = SUM_LENGTH;
check_for_finished_hlinks(itemizing, code);
if ((i = get_redo_num()) == -1) {
- if (incremental)
+ if (inc_recurse)
break;
wait_for_receiver();
continue;
make_backups = -make_backups;
ignore_times--;
- if (!incremental)
+ if (!inc_recurse)
break;
while (!cur_flist->next && !flist_eof)
wait_for_receiver();
next_flist = cur_flist->next;
while (first_flist != next_flist) {
- struct file_struct *fp;
if (first_flist->in_progress || first_flist->to_redo) {
if (next_flist)
break;
}
cur_flist = first_flist;
- if (cur_flist->ndx_start != 0) {
- fp = dir_flist->files[cur_flist->parent_ndx];
- if (!(fp->flags & FLAG_MISSING_DIR)) {
- f_name(fp, fbuf);
- if (!(fp->mode & S_IWUSR))
- do_chmod(fbuf, fp->mode);
- if (preserve_times && !omit_dir_times) {
- set_modtime(fbuf, fp->modtime,
- fp->mode);
- }
- }
- } else if (relative_paths && implied_dirs
- && preserve_times && !omit_dir_times) {
- /* Set mtime on implied dirs */
- for (i = 0; i < cur_flist->count; i++) {
- fp = cur_flist->files[i];
- if (!S_ISDIR(fp->mode)
- || fp->flags & (FLAG_XFER_DIR|FLAG_MISSING_DIR))
- continue;
- f_name(fp, fbuf);
- set_modtime(fbuf, fp->modtime, fp->mode);
- }
+ if (delete_during == 2 || !dir_tweaking) {
+ /* Skip directory touch-up. */
+ } else if (cur_flist->ndx_start != 0) {
+ touch_up_dirs(dir_flist, cur_flist->parent_ndx,
+ need_retouch_dir_times, lull_mod);
+ } else if (relative_paths && implied_dirs) {
+ touch_up_dirs(cur_flist, -1,
+ need_retouch_dir_times, lull_mod);
}
- flist_free(cur_flist);
+ flist_free(first_flist); /* updates cur_flist & first_flist */
if (!read_batch)
- write_int(f_out, NDX_DONE);
+ write_ndx(f_out, NDX_DONE);
}
} while ((cur_flist = next_flist) != NULL);
if (verbose > 2)
rprintf(FINFO, "generate_files phase=%d\n", phase);
- write_int(f_out, NDX_DONE);
+ write_ndx(f_out, NDX_DONE);
/* Reduce round-trip lag-time for a useless delay-updates phase. */
if (protocol_version >= 29 && !delay_updates)
- write_int(f_out, NDX_DONE);
+ write_ndx(f_out, NDX_DONE);
/* Read MSG_DONE for the redo phase (and any prior messages). */
while (done_cnt <= 1) {
if (verbose > 2)
rprintf(FINFO, "generate_files phase=%d\n", phase);
if (delay_updates)
- write_int(f_out, NDX_DONE);
+ write_ndx(f_out, NDX_DONE);
/* Read MSG_DONE for delay-updates phase & prior messages. */
while (done_cnt == 2)
wait_for_receiver();
do_delete_pass(cur_flist);
if ((need_retouch_dir_perms || need_retouch_dir_times)
- && dir_tweaking && !incremental) {
- int j = 0;
- /* Now we need to fix any directory permissions that were
- * modified during the transfer and/or re-set any tweaked
- * modified-time values. */
- for (i = 0; i < cur_flist->count; i++) {
- struct file_struct *file = cur_flist->files[i];
- if (!F_IS_ACTIVE(file) || !S_ISDIR(file->mode))
- continue;
- if (!need_retouch_dir_times && file->mode & S_IWUSR)
- continue;
- if (file->flags & FLAG_MISSING_DIR) {
- int missing = F_DEPTH(file);
- while (++i < cur_flist->count) {
- file = cur_flist->files[i];
- if (F_DEPTH(file) <= missing)
- break;
- }
- i--;
- continue;
- }
- recv_generator(f_name(file, NULL), file, i, itemizing,
- code, -1);
- if (allowed_lull && !(++j % lull_mod))
- maybe_send_keepalive();
- else if (!(j % 200))
- maybe_flush_socket();
- }
+ && dir_tweaking && (!inc_recurse || delete_during == 2)) {
+ touch_up_dirs(inc_recurse ? dir_flist : cur_flist, -1,
+ need_retouch_dir_times, lull_mod);
}
if (max_delete >= 0 && deletion_count > max_delete) {