extern int protocol_version;
extern int sanitize_paths;
extern struct stats stats;
-@@ -78,6 +79,8 @@ static dev_t tmp_rdev;
+@@ -77,6 +78,8 @@ static dev_t tmp_rdev;
static struct idev tmp_idev;
static char tmp_sum[MD4_SUM_LENGTH];
static char empty_sum[MD4_SUM_LENGTH];
static int flist_count_offset;
-@@ -260,6 +263,44 @@ static mode_t from_wire_mode(int mode)
+@@ -259,6 +262,44 @@ static mode_t from_wire_mode(int mode)
return mode;
}
static void send_directory(int f, struct file_list *flist,
char *fbuf, int len);
-@@ -1395,6 +1436,25 @@ struct file_list *recv_file_list(int f)
+@@ -1411,6 +1452,25 @@ struct file_list *recv_file_list(int f)
clean_flist(flist, relative_paths, 1);
--- old/generator.c
+++ new/generator.c
-@@ -77,6 +77,7 @@ extern char *basis_dir[];
+@@ -76,6 +76,7 @@ extern char *basis_dir[];
extern int compare_dest;
extern int copy_dest;
extern int link_dest;
extern int whole_file;
extern int list_only;
extern int new_root_dir;
-@@ -93,15 +94,18 @@ extern char *backup_dir;
+@@ -91,16 +92,19 @@ extern char *backup_dir;
extern char *backup_suffix;
extern int backup_suffix_len;
extern struct file_list *the_file_list;
static int deletion_count = 0; /* used to implement --max-delete */
+static int unexplored_dirs = 1;
static FILE *delete_delay_fp = NULL;
+ static BOOL solo_file = 0;
-/* 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 */
-@@ -123,11 +127,121 @@ static int is_backup_file(char *fn)
+@@ -122,11 +126,121 @@ 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)
{
-@@ -149,6 +263,8 @@ static enum delret delete_item(char *fbu
+@@ -148,6 +262,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;
-@@ -195,6 +311,8 @@ static enum delret delete_item(char *fbu
+@@ -194,6 +310,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)
{
-@@ -251,6 +369,8 @@ static enum delret delete_dir_contents(c
+@@ -250,6 +368,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;
}
-@@ -335,15 +455,19 @@ static void delayed_deletions(char *delb
+@@ -334,15 +454,19 @@ static void delayed_deletions(char *delb
* 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) {
-@@ -357,6 +481,8 @@ static void delete_in_dir(struct file_li
+@@ -356,6 +480,8 @@ static void delete_in_dir(struct file_li
if (verbose > 2)
rprintf(FINFO, "delete_in_dir(%s)\n", fbuf);
if (allowed_lull)
maybe_send_keepalive();
-@@ -364,12 +490,14 @@ static void delete_in_dir(struct file_li
+@@ -363,12 +489,14 @@ static void delete_in_dir(struct file_li
return; /* Impossible... */
if (io_error && !(lp_ignore_errors(module_id) || ignore_errors)) {
}
while (cur_depth >= file->dir.depth && cur_depth >= min_depth)
-@@ -380,6 +508,9 @@ static void delete_in_dir(struct file_li
+@@ -379,6 +507,9 @@ static void delete_in_dir(struct file_li
dlen = strlen(fbuf);
filt_array[cur_depth] = push_local_filters(fbuf, dlen);
if (one_file_system) {
if (file->flags & FLAG_TOP_DIR)
filesystem_dev = stp->st_dev;
-@@ -389,6 +520,11 @@ static void delete_in_dir(struct file_li
+@@ -388,6 +519,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--; ) {
-@@ -401,15 +537,22 @@ static void delete_in_dir(struct file_li
+@@ -400,15 +536,22 @@ static void delete_in_dir(struct file_li
f_name(fp, NULL));
continue;
}
flist_free(dirlist);
}
-@@ -439,9 +582,9 @@ static void do_delete_pass(struct file_l
+@@ -438,9 +581,9 @@ static void do_delete_pass(struct file_l
|| !S_ISDIR(st.st_mode))
continue;
if (do_progress && !am_server)
rprintf(FINFO, " \r");
-@@ -966,6 +1109,7 @@ static int try_dests_non(struct file_str
+@@ -971,6 +1114,7 @@ static int try_dests_non(struct file_str
return j;
}
static int phase = 0;
/* Acts on the_file_list->file's ndx'th item, whose name is fname. If a dir,
-@@ -1152,8 +1296,12 @@ static void recv_generator(char *fname,
+@@ -1157,8 +1301,12 @@ static void recv_generator(char *fname,
if (real_ret != 0 && one_file_system)
real_st.st_dev = filesystem_dev;
if (delete_during && f_out != -1 && !phase && dry_run < 2
return;
}
-@@ -1406,8 +1554,14 @@ static void recv_generator(char *fname,
- && hard_link_check(file, ndx, fname, statret, &st,
+@@ -1429,8 +1577,14 @@ static void recv_generator(char *fname,
itemizing, code, HL_SKIP))
return;
+ #endif
- if (stat_errno == ENOENT)
+ if (stat_errno == ENOENT) {
+ if (detect_renamed && unexplored_dirs > 0
rsyserr(FERROR, stat_errno, "recv_generator: failed to stat %s",
full_fname(fname));
return;
-@@ -1593,13 +1747,19 @@ void generate_files(int f_out, struct fi
+@@ -1619,13 +1773,19 @@ void generate_files(int f_out, struct fi
(long)getpid(), flist->count);
}
whole_file = 0;
if (verbose >= 2) {
rprintf(FINFO, "delta-transmission %s\n",
-@@ -1654,7 +1814,23 @@ void generate_files(int f_out, struct fi
+@@ -1682,7 +1842,23 @@ void generate_files(int f_out, struct fi
}
recv_generator(NULL, NULL, 0, 0, 0, code, -1);
if (delete_during)