while (future_cnt < at_least) {
struct file_struct *file = dir_flist->sorted[send_dir_ndx];
int dir_ndx, dstart = dir_count;
+ const char *pathname = F_PATHNAME(file);
int32 *dp;
flist = flist_new(0, "send_extra_file_list");
&& dir_flist->sorted[dir_ndx]->flags & FLAG_DUPLICATE) {
send_dir_ndx = dir_ndx;
file = dir_flist->sorted[dir_ndx];
- send1extra(f, file, flist);
+ if (F_PATHNAME(file) != pathname)
+ send1extra(f, file, flist);
dp = F_DIR_NODE_P(file);
}
int keep, drop;
/* If one is a dir and the other is not, we want to
* keep the dir because it might have contents in the
- * list. If both are dirs, keep the last one.
- * Otherwise keep the first one. */
- if (S_ISDIR(file->mode))
- keep = i, drop = j;
- else
+ * list. Otherwise keep the first one. */
+ if (S_ISDIR(file->mode)) {
+ struct file_struct *fp = flist->sorted[j];
+ if (!S_ISDIR(fp->mode) || !(fp->flags & FLAG_XFER_DIR))
+ keep = i, drop = j;
+ else {
+ if (am_sender)
+ file->flags |= FLAG_DUPLICATE;
+ keep = j, drop = i;
+ }
+ } else
keep = j, drop = i;
- if (am_sender)
- flist->sorted[drop]->flags |= FLAG_DUPLICATE;
- else {
+ if (!am_sender) {
if (verbose > 1) {
rprintf(FINFO,
"removing duplicate name %s from file list (%d)\n",