From 4aeb093206d55c3d886cbcec062f7aa93d0b968e Mon Sep 17 00:00:00 2001
From: Wayne Davison <wayned@samba.org>
Date: Tue, 20 Nov 2018 12:45:36 -0800
Subject: [PATCH 05/36] Fix itemizing of wrong dir name on some --iconv
 transfers.

Fixes bug #13492.

Signed-off-by: root <root@localhost.localdomain>
---
 flist.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/flist.c b/flist.c
index 499440cc..60e843cc 100644
--- a/flist.c
+++ b/flist.c
@@ -1636,6 +1636,7 @@ static void add_dirs_to_tree(int parent_ndx, struct file_list *from_flist,
 	int32 *parent_dp = parent_ndx < 0 ? NULL
 			 : F_DIR_NODE_P(dir_flist->sorted[parent_ndx]);
 
+	/* The sending side is adding entries to dir_flist in sorted order, so sorted & files are the same. */
 	flist_expand(dir_flist, dir_cnt);
 	dir_flist->sorted = dir_flist->files;
 
@@ -1970,7 +1971,7 @@ void send_extra_file_list(int f, int at_least)
 		else
 			dir_ndx = send_dir_ndx;
 		write_ndx(f, NDX_FLIST_OFFSET - dir_ndx);
-		flist->parent_ndx = dir_ndx;
+		flist->parent_ndx = send_dir_ndx; /* the sending side must remember the sorted ndx value */
 
 		send1extra(f, file, flist);
 		prev_flags = file->flags;
-- 
2.19.1

