static void send_directory(int f, struct file_list *flist, int ndx,
char *fbuf, int len, int flags);
-@@ -1702,6 +1744,25 @@ struct file_list *recv_file_list(int f)
+@@ -1711,6 +1753,25 @@ struct file_list *recv_file_list(int f)
clean_flist(flist, relative_paths, 1);
+ the_fattr_list.high = j;
+ }
+
- if (incremental) {
+ if (inc_recurse) {
qsort(dir_flist->files + dstart, dir_flist->count - dstart,
sizeof dir_flist->files[0], (int (*)())file_compare);
--- old/generator.c
int ignore_perishable = 0;
int non_perishable_cnt = 0;
-@@ -102,12 +104,14 @@ int maybe_ATTRS_REPORT = 0;
+@@ -102,6 +104,7 @@ int maybe_ATTRS_REPORT = 0;
static dev_t dev_zero;
static int deletion_count = 0; /* used to implement --max-delete */
static int deldelay_size = 0, deldelay_cnt = 0;
static char *deldelay_buf = NULL;
static int deldelay_fd = -1;
- static BOOL solo_file = 0;
+@@ -110,7 +113,8 @@ static int dir_tweaking;
+ static int need_retouch_dir_times;
+ static const char *solo_file = NULL;
-/* For calling delete_item() and delete_dir_contents(). */
+/* For calling delete_item(), delete_dir_contents(), and delete_in_dir(). */
#define DEL_RECURSE (1<<1) /* recurse */
#define DEL_DIR_IS_EMPTY (1<<2) /* internal delete_FUNCTIONS use only */
-@@ -129,11 +133,120 @@ static int is_backup_file(char *fn)
+@@ -132,11 +136,120 @@ static int is_backup_file(char *fn)
return k > 0 && strcmp(fn+k, backup_suffix) == 0;
}
*/
static enum delret delete_item(char *fbuf, int mode, char *replace, int flags)
{
-@@ -155,6 +268,8 @@ static enum delret delete_item(char *fbu
+@@ -158,6 +271,8 @@ static enum delret delete_item(char *fbu
goto check_ret;
/* OK: try to delete the directory. */
}
if (!replace && max_delete >= 0 && ++deletion_count > max_delete)
return DR_AT_LIMIT;
-@@ -201,6 +316,8 @@ static enum delret delete_item(char *fbu
+@@ -204,6 +319,8 @@ static enum delret delete_item(char *fbu
* its contents, otherwise just checks for content. Returns DR_SUCCESS or
* DR_NOT_EMPTY. Note that fname must point to a MAXPATHLEN buffer! (The
* buffer is used for recursion, but returned unchanged.)
*/
static enum delret delete_dir_contents(char *fname, int flags)
{
-@@ -220,7 +337,9 @@ static enum delret delete_dir_contents(c
+@@ -223,7 +340,9 @@ static enum delret delete_dir_contents(c
save_filters = push_local_filters(fname, dlen);
non_perishable_cnt = 0;
ret = non_perishable_cnt ? DR_NOT_EMPTY : DR_SUCCESS;
if (!dirlist->count)
-@@ -257,6 +376,8 @@ static enum delret delete_dir_contents(c
+@@ -260,6 +379,8 @@ static enum delret delete_dir_contents(c
if (S_ISDIR(fp->mode)
&& delete_dir_contents(fname, flags | DEL_RECURSE) != DR_SUCCESS)
ret = DR_NOT_EMPTY;
if (delete_item(fname, fp->mode, NULL, flags) != DR_SUCCESS)
ret = DR_NOT_EMPTY;
}
-@@ -409,13 +530,17 @@ static void do_delayed_deletions(char *d
+@@ -412,13 +533,17 @@ static void do_delayed_deletions(char *d
* all the --delete-WHEN options. Note that the fbuf pointer must point to a
* MAXPATHLEN buffer with the name of the directory in it (the functions we
* call will append names onto the end, but the old dir value will be restored
int dlen, i;
if (!flist) {
-@@ -426,21 +551,28 @@ static void delete_in_dir(struct file_li
+@@ -429,21 +554,28 @@ static void delete_in_dir(struct file_li
if (verbose > 2)
rprintf(FINFO, "delete_in_dir(%s)\n", fbuf);
if (one_file_system) {
if (file->flags & FLAG_TOP_DIR)
filesystem_dev = *fs_dev;
-@@ -450,6 +582,11 @@ static void delete_in_dir(struct file_li
+@@ -453,6 +585,11 @@ static void delete_in_dir(struct file_li
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--; ) {
-@@ -462,16 +599,23 @@ static void delete_in_dir(struct file_li
+@@ -465,16 +602,23 @@ static void delete_in_dir(struct file_li
f_name(fp, NULL));
continue;
}
flist_free(dirlist);
}
-@@ -501,9 +645,9 @@ static void do_delete_pass(struct file_l
+@@ -504,9 +648,9 @@ static void do_delete_pass(struct file_l
|| !S_ISDIR(st.st_mode))
continue;
if (do_progress && !am_server)
rprintf(FINFO, " \r");
-@@ -1038,6 +1182,7 @@ static int try_dests_non(struct file_str
+@@ -1023,6 +1167,7 @@ static int try_dests_non(struct file_str
return j;
}
static int phase = 0;
/* Acts on cur_flist->file's ndx'th item, whose name is fname. If a dir,
-@@ -1229,8 +1374,12 @@ static void recv_generator(char *fname,
+@@ -1214,8 +1359,12 @@ static void recv_generator(char *fname,
}
}
else if (delete_during && f_out != -1 && !phase && dry_run < 2
return;
}
-@@ -1494,8 +1643,14 @@ static void recv_generator(char *fname,
+@@ -1479,8 +1628,14 @@ static void recv_generator(char *fname,
if (preserve_hard_links && F_HLINK_NOT_LAST(file))
return;
#endif
rsyserr(FERROR, stat_errno, "recv_generator: failed to stat %s",
full_fname(fname));
return;
-@@ -1683,6 +1838,12 @@ void generate_files(int f_out, char *loc
+@@ -1775,6 +1930,12 @@ void generate_files(int f_out, const cha
if (verbose > 2)
rprintf(FINFO, "generator starting pid=%ld\n", (long)getpid());
+ delete_during = -1;
+ }
+
- if (delete_before && !local_name && cur_flist->count > 0)
+ if (delete_before && !solo_file && cur_flist->count > 0)
do_delete_pass(cur_flist);
if (delete_during == 2) {
-@@ -1693,7 +1854,7 @@ void generate_files(int f_out, char *loc
+@@ -1785,7 +1946,7 @@ void generate_files(int f_out, const cha
}
do_progress = 0;
whole_file = 0;
if (verbose >= 2) {
rprintf(FINFO, "delta-transmission %s\n",
-@@ -1718,7 +1879,7 @@ void generate_files(int f_out, char *loc
+@@ -1810,7 +1971,7 @@ void generate_files(int f_out, const cha
dirdev = MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp));
} else
dirdev = MAKEDEV(0, 0);
}
}
for (i = cur_flist->low; i <= cur_flist->high; i++) {
-@@ -1764,7 +1925,21 @@ void generate_files(int f_out, char *loc
-
- if (!incremental) {
- if (delete_during)
-- delete_in_dir(NULL, NULL, NULL, &dev_zero);
-+ delete_in_dir(NULL, NULL, NULL, &dev_zero, 0);
-+ if (detect_renamed) {
-+ if (delete_during < 0)
-+ delete_during = 0;
-+ detect_renamed = 0;
+@@ -1863,7 +2024,21 @@ void generate_files(int f_out, const cha
+ } while ((cur_flist = cur_flist->next) != NULL);
+
+ if (delete_during)
+- delete_in_dir(NULL, NULL, NULL, &dev_zero);
++ delete_in_dir(NULL, NULL, NULL, &dev_zero, 0);
++ if (detect_renamed) {
++ if (delete_during < 0)
++ delete_during = 0;
++ detect_renamed = 0;
+
-+ for (i = -1; (i = bitbag_next_bit(delayed_bits, i)) >= 0; ) {
-+ struct file_struct *file = flist->files[i];
-+ if (local_name)
-+ strlcpy(fbuf, local_name, sizeof fbuf);
-+ else
-+ f_name(file, fbuf);
-+ recv_generator(fbuf, file, i, itemizing, code, f_out);
-+ }
-+ }
- phase++;
- if (verbose > 2) {
- rprintf(FINFO, "generate_files phase=%d\n",
++ for (i = -1; (i = bitbag_next_bit(delayed_bits, i)) >= 0; ) {
++ struct file_struct *file = flist->files[i];
++ if (local_name)
++ strlcpy(fbuf, local_name, sizeof fbuf);
++ else
++ f_name(file, fbuf);
++ recv_generator(fbuf, file, i, itemizing, code, f_out);
++ }
++ }
+ phase++;
+ if (verbose > 2)
+ rprintf(FINFO, "generate_files phase=%d\n", phase);
--- old/options.c
+++ new/options.c
@@ -78,6 +78,7 @@ int am_generator = 0;
--compare-dest=DIR also compare received files relative to DIR
--copy-dest=DIR ... and include copies of unchanged files
--link-dest=DIR hardlink to files in DIR when unchanged
-@@ -1272,6 +1273,15 @@ Note that the use of the bf(--delete) op
+@@ -1296,6 +1297,15 @@ Note that the use of the bf(--delete) op
fuzzy-match files, so either use bf(--delete-after) or specify some
filename exclusions if you need to prevent this.