- write_ndx(f, NDX_FLIST_OFFSET - send_dir_ndx);
- change_local_filter_dir(fbuf, dlen, send_dir_depth);
- send_directory(f, flist, send_dir_ndx, fbuf, dlen, FLAG_DIVERT_DIRS | FLAG_XFER_DIR);
+ /* If this is the first of a set of duplicate dirs, we must
+ * send all the dirs together in a single file-list. We must
+ * also send the index of the last dir in the header. */
+ if (file->flags & FLAG_DUPLICATE) {
+ int dir_ndx, end_ndx = send_dir_ndx;
+ struct file_struct *fp = file;
+
+ while (1) {
+ dp = F_DIRNODE_P(fp);
+ end_ndx = DIR_NEXT_SIBLING(dp);
+ fp = dir_flist->sorted[end_ndx];
+ if (!(fp->flags & FLAG_DUPLICATE))
+ break;
+ }
+
+#ifdef ICONV_OPTION
+ if (ic_ndx)
+ dir_ndx = F_NDX(fp);
+ else
+#endif
+ dir_ndx = end_ndx;
+ write_ndx(f, NDX_FLIST_OFFSET - dir_ndx);
+
+ while (1) {
+ send1extra(f, file, flist);
+ if (send_dir_ndx == end_ndx)
+ break;
+ dp = F_DIRNODE_P(file);
+ send_dir_ndx = DIR_NEXT_SIBLING(dp);
+ file = dir_flist->sorted[send_dir_ndx];
+ }
+ } else {
+ int dir_ndx;
+#ifdef ICONV_OPTION
+ if (ic_ndx)
+ dir_ndx = F_NDX(file);
+ else
+#endif
+ dir_ndx = send_dir_ndx;
+ write_ndx(f, NDX_FLIST_OFFSET - dir_ndx);
+
+ send1extra(f, file, flist);
+ }