FluentFTP: `DownloadDirectory` throws `System.ArgumentException: An item with the same key has already been added`
Hello - we are using this libary to download files from our robot controllers. I’m finding that on some of the controllers we’re getting a crash - it appears that the file name is failing to be parsed and two different files are both treated as having no name.
System.ArgumentException: An item with the same key has already been added. Key: c:\users\karbonsp\appdata\local\temp\5xls3htj.jud\rc_3\md:
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at FluentFTP.Client.Modules.FileDownloadModule.RecordFileToDownload(BaseFtpClient client, List`1 rules, List`1 results, Dictionary`2 shouldExist, List`1 toDownload, FtpListItem remoteFile, String localFile, String remoteFilePath)
at FluentFTP.Client.Modules.FileDownloadModule.GetFilesToDownload(BaseFtpClient client, String localFolder, String remoteFolder, List`1 rules, List`1 results, FtpListItem[] listing, Dictionary`2 shouldExist)
at FluentFTP.AsyncFtpClient.DownloadDirectory(String localFolder, String remoteFolder, FtpFolderSyncMode mode, FtpLocalExists existsMode, FtpVerify verifyOptions, List`1 rules, IProgress`1 progress, CancellationToken token)
I’ve glanced at some of this code, and I find that somewhere you’re getting an empty filename for two files. It appears that the parser is not properly interpreting the response.
listing.GroupBy(_ => _.FullName).Where(_ => _.Count() > 1).SelectMany(_ => _).Select(_ => _.Name)
{System.Linq.Enumerable.SelectEnumerableIterator<FluentFTP.FtpListItem, string>}
[0]: ""
[1]: ""
listing.GroupBy(_ => _.FullName).Where(_ => _.Count() > 1).SelectMany(_ => _).Select(_ => _.Input)
{System.Linq.Enumerable.SelectEnumerableIterator<FluentFTP.FtpListItem, string>}
[0]: "-rw-rw-rw- 1 noone nogroup 0 000 16 2030 axistestg2.ls"
[1]: "-rw-rw-rw- 1 noone nogroup 132 000 16 2030 axistestg2.tp"
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18
Thanks - our project is not open-source, so for now I will leave things with the workaround. Thanks for your help!
That prevents the call to
DownloadDirectoryfrom crashing, correct. We need the part in theifstatement in order for those two files to appear in the output directory.