From be2218afcc9ff480288e860c5391af262b997d1f Mon Sep 17 00:00:00 2001 From: Rick Brown Date: Sat, 7 Oct 2023 17:30:32 -0400 Subject: [PATCH] Bugfix for issue #2423 - FTP contents invisible Change working directory to target path and call GetListing on current directory instead of calling GetListing on explicit path. For some reason GetListing(path) does not always return the contents of the directory. However, calling SetWorkingDirectory(path) followed by GetListing(null, options) to list the contents of the working directory does consistently work. Similar behavior was confirmed using ncftp client. I suspect this is a strange bug/nuance in the server's implementation of the LIST command? --- src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs b/src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs index cea724a5..db5debd8 100644 --- a/src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs +++ b/src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs @@ -288,8 +288,20 @@ namespace keepass2android.Io { using (var client = GetClient(ioc)) { + /* + * For some reason GetListing(path) does not always return the contents of the directory. + * However, calling SetWorkingDirectory(path) followed by GetListing(null, options) to + * list the contents of the working directory does consistently work. + * + * Similar behavior was confirmed using ncftp client. I suspect this is a strange + * bug/nuance in the server's implementation of the LIST command? + * + * [bug #2423] + */ + client.SetWorkingDirectory(IocToLocalPath(ioc)); + List files = new List(); - foreach (FtpListItem item in client.GetListing(IocToLocalPath(ioc), + foreach (FtpListItem item in client.GetListing(null, FtpListOption.Modify | FtpListOption.Size | FtpListOption.DerefLinks)) {