CoreFTP icon indicating copy to clipboard operation
CoreFTP copied to clipboard

Random System.IndexOutOfRangeException when changing directory

Open qaramelus opened this issue 6 years ago • 1 comments

Hi there,

I've got a nightly process running that uses your library. Many thanks for making it available. However, this line https://github.com/sparkeh9/CoreFTP/blob/master/src/CoreFtp/FtpClient.cs#L170 randomly throws an exception:

System.IndexOutOfRangeException: Index was outside the bounds of the array. at CoreFtp.FtpClient.ChangeWorkingDirectoryAsync(String directory) at CoreFtp.FtpClient.CreateDirectoryStructureRecursively(IReadOnlyCollection`1 directories, Boolean isRootedPath) at CoreFtp.FtpClient.OpenFileWriteStreamAsync(String fileName)

For I guess the response does not always contain a double quote.

This is totally random, I upload one file every night (with the same filename format, to the same target ftp directory) and sometimes the log shows the exception and sometimes all goes smoothly.

For now, I retry the upload operation with Polly (http://www.thepollyproject.org/) and has always succeeded at the first retry.

qaramelus avatar Jan 28 '19 08:01 qaramelus

I Use login ftp for each change directory and it's work properly. For example:

                    await ftpClient.LoginAsync();
                    using (var writeStream = await ftpClient.OpenFileWriteStreamAsync("photos/customer/original/" + fileName))
                    {
                        var fileReadStream = fileinfoOriginal.OpenRead();
                        await fileReadStream.CopyToAsync(writeStream);
                    }
                    await ftpClient.LoginAsync();
                    using (var writeStream = await ftpClient.OpenFileWriteStreamAsync("photos/customer/thumb/" + fileName))
                    {
                        var fileReadStream = fileinfoThumb.OpenRead();
                        await fileReadStream.CopyToAsync(writeStream);
                    }

HekmatBeigverdi avatar Nov 24 '21 08:11 HekmatBeigverdi