| 2091 | #endif |
| 2092 | |
| 2093 | static void touch_up_dirs(struct file_list *flist, int ndx) |
| 2094 | { |
| 2095 | static int counter = 0; |
| 2096 | struct file_struct *file; |
| 2097 | char *fname; |
| 2098 | BOOL fix_dir_perms; |
| 2099 | int i, start, end; |
| 2100 | |
| 2101 | if (ndx < 0) { |
| 2102 | start = 0; |
| 2103 | end = flist->used - 1; |
| 2104 | } else |
| 2105 | start = end = ndx; |
| 2106 | |
| 2107 | /* Fix any directory permissions that were modified during the |
| 2108 | * transfer and/or re-set any tweaked modified-time values. */ |
| 2109 | for (i = start; i <= end; i++, counter++) { |
| 2110 | file = flist->files[i]; |
| 2111 | if (!F_IS_ACTIVE(file)) |
| 2112 | continue; |
| 2113 | if (!S_ISDIR(file->mode) |
| 2114 | || (!implied_dirs && file->flags & FLAG_IMPLIED_DIR)) |
| 2115 | continue; |
| 2116 | if (DEBUG_GTE(TIME, 2)) { |
| 2117 | fname = f_name(file, NULL); |
| 2118 | rprintf(FINFO, "touch_up_dirs: %s (%d)\n", |
| 2119 | NS(fname), i); |
| 2120 | } |
| 2121 | /* Be sure not to retouch permissions with --fake-super. */ |
| 2122 | fix_dir_perms = !am_root && !(file->mode & S_IWUSR); |
| 2123 | if (file->flags & FLAG_MISSING_DIR || !(need_retouch_dir_times || fix_dir_perms)) |
| 2124 | continue; |
| 2125 | fname = f_name(file, NULL); |
| 2126 | if (fix_dir_perms) |
| 2127 | do_chmod_at(fname, file->mode); |
| 2128 | if (need_retouch_dir_times) { |
| 2129 | STRUCT_STAT st; |
| 2130 | if (link_stat(fname, &st, 0) == 0 && mtime_differs(&st, file)) { |
| 2131 | st.st_mtime = file->modtime; |
| 2132 | #ifdef ST_MTIME_NSEC |
| 2133 | st.ST_MTIME_NSEC = F_MOD_NSEC_or_0(file); |
| 2134 | #endif |
| 2135 | set_times(fname, &st); |
| 2136 | } |
| 2137 | } |
| 2138 | if (counter >= loopchk_limit) { |
| 2139 | if (allowed_lull) |
| 2140 | maybe_send_keepalive(time(NULL), MSK_ALLOW_FLUSH); |
| 2141 | else |
| 2142 | maybe_flush_socket(0); |
| 2143 | counter = 0; |
| 2144 | } |
| 2145 | } |
| 2146 | } |
| 2147 | |
| 2148 | void check_for_finished_files(int itemizing, enum logcode code, int check_redo) |
| 2149 | { |
no test coverage detected