+ if (verbose > 2)
+ rprintf(FINFO, "delete_in_dir(%s)\n", safe_fname(fbuf));
+
+ if (allowed_lull)
+ maybe_send_keepalive(allowed_lull, flist->count);
+
+ if (file->dir.depth >= MAXPATHLEN/2+1)
+ return; /* Impossible... */
+
+ if (max_delete && deletion_count >= max_delete)
+ return;
+
+ if (io_error && !(lp_ignore_errors(module_id) || ignore_errors)) {
+ rprintf(FINFO,
+ "IO error encountered -- skipping file deletion\n");
+ max_delete = -1; /* avoid duplicating the above warning */
+ return;
+ }
+
+ while (cur_depth >= file->dir.depth && cur_depth >= min_depth)
+ pop_local_filters(filt_array[cur_depth--]);
+ cur_depth = file->dir.depth;
+ if (min_depth > cur_depth)
+ min_depth = cur_depth;
+ dlen = strlen(fbuf);
+ filt_array[cur_depth] = push_local_filters(fbuf, dlen);
+
+ if (link_stat(fbuf, &st, keep_dirlinks) < 0)
+ return;
+
+ if (one_file_system && file->flags & FLAG_TOP_DIR)
+ filesystem_dev = st.st_dev;
+
+ dirlist = get_dirlist(fbuf, dlen, 0);
+
+ /* If an item in dirlist is not found in flist, delete it
+ * from the filesystem. */
+ for (i = dirlist->count; i--; ) {
+ if (!dirlist->files[i]->basename)
+ continue;
+ if (flist_find(flist, dirlist->files[i]) < 0) {
+ int mode = dirlist->files[i]->mode;
+ f_name_to(dirlist->files[i], delbuf);
+ if (delete_item(delbuf, mode, DEL_FORCE_RECURSE) < 0)
+ break;
+ }
+ }
+
+ flist_free(dirlist);