+ if (ndx < 0) {
+ start = 0;
+ end = flist->used - 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; i <= end; i++, counter++) {
+ file = flist->files[i];
+ if (!S_ISDIR(file->mode)
+ || (!implied_dirs && file->flags & FLAG_IMPLIED_DIR))
+ continue;
+ if (verbose > 3) {
+ fname = f_name(file, NULL);
+ rprintf(FINFO, "touch_up_dirs: %s (%d)\n",
+ NS(fname), i);
+ }
+ if (!F_IS_ACTIVE(file) || file->flags & FLAG_MISSING_DIR
+ || (!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 && !(counter % lull_mod))
+ maybe_send_keepalive();
+ else if (!(counter & 0xFF))
+ maybe_flush_socket(0);
+ }
+}
+
+void check_for_finished_files(int itemizing, enum logcode code, int check_redo)
+{
+ struct file_struct *file;
+ struct file_list *flist;
+ char fbuf[MAXPATHLEN];
+ int ndx;
+
+#ifdef SUPPORT_HARD_LINKS
+ while (preserve_hard_links && (ndx = get_hlink_num()) != -1) {
+ flist = flist_for_ndx(ndx);
+ assert(flist != NULL);
+ file = flist->files[ndx - flist->ndx_start];
+ assert(file->flags & FLAG_HLINKED);
+ finish_hard_link(file, f_name(file, fbuf), ndx, NULL, itemizing, code, -1);
+ flist->in_progress--;
+ }
+#endif
+
+ while (check_redo && (ndx = get_redo_num()) != -1) {
+ csum_length = SUM_LENGTH;
+ max_size = -max_size;
+ min_size = -min_size;
+ ignore_existing = -ignore_existing;
+ ignore_non_existing = -ignore_non_existing;
+ update_only = -update_only;
+ always_checksum = -always_checksum;
+ size_only = -size_only;
+ append_mode = -append_mode;
+ make_backups = -make_backups; /* avoid dup backup w/inplace */
+ ignore_times++;
+
+ flist = cur_flist;
+ cur_flist = flist_for_ndx(ndx);
+
+ file = cur_flist->files[ndx - cur_flist->ndx_start];
+ if (solo_file)
+ strlcpy(fbuf, solo_file, sizeof fbuf);
+ else
+ f_name(file, fbuf);
+ recv_generator(fbuf, file, ndx, itemizing, code, sock_f_out);
+ cur_flist->to_redo--;
+
+ cur_flist = flist;
+
+ csum_length = SHORT_SUM_LENGTH;
+ max_size = -max_size;
+ min_size = -min_size;
+ ignore_existing = -ignore_existing;
+ ignore_non_existing = -ignore_non_existing;
+ update_only = -update_only;
+ always_checksum = -always_checksum;
+ size_only = -size_only;
+ append_mode = -append_mode;
+ make_backups = -make_backups;
+ ignore_times--;
+ }
+
+ while (cur_flist != first_flist) { /* only possible with inc_recurse */
+ if (first_flist->in_progress || first_flist->to_redo)
+ break;
+
+ if (!read_batch) {
+ write_ndx(sock_f_out, NDX_DONE);
+ maybe_flush_socket(1);
+ }
+
+ if (delete_during == 2 || !dir_tweaking) {
+ /* Skip directory touch-up. */
+ } else if (first_flist->parent_ndx >= 0)
+ touch_up_dirs(dir_flist, first_flist->parent_ndx);
+
+ flist_free(first_flist); /* updates first_flist */
+ }
+}
+
+void generate_files(int f_out, const char *local_name)