UploadDirectory in Mirror mode occasionally deletes destination folder's entire contents
FTP Server OS: Windows FTP Server Type: Windows Server IIS Client Computer OS: Windows FluentFTP Version: 50.0.1 Framework: .NET 4.8.1
I have an app that generates around 1000 XML files (in subfolders). It then uploads a mirror to the FTP server. So, most of the time it's overwriting files with newer versions of themselves. Occasionally, if there are files to remove, it will remove ALL files, not just the extras. The FtpResults report success.
No logs at this stage...
Well. Until there are logs there is only one slight idea what might be going wrong:
If a folder listing somehow fails, unrecognized, the mirror operation might decide that mirrored folder needs to be empty also.
But without a log of a specific occurrence? Very difficult.
It uploaded the files, recorded them as successful in the FtpResults, THEN deleted them.
I've done a workaround - delete folder, create folder, upload in Update mode.
On Sat, 25 May 2024, 3:46 am FanDjango, @.***> wrote:
Well. Until there are logs there is only one slight idea what might be going wrong:
If a folder listing somehow fails, unrecognized, the mirror operation might decide that mirrored folder needs to be empty also.
But without a log of a specific occurrence? Very difficult.
— Reply to this email directly, view it on GitHub https://github.com/robinrodricks/FluentFTP/issues/1580#issuecomment-2130118301, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYK2FUGF6NHBPMP5DZ57O3ZD57YLAVCNFSM6AAAAABIHBAX52VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZQGEYTQMZQGE . You are receiving this because you authored the thread.Message ID: @.***>
It uploaded the files, recorded them as successful in the FtpResults, THEN deleted them.
Wow. Need to check the code how that can happen.
Code has some logging to show up what it is doing and why.
LogWithPrefix(FtpTraceLevel.Info, "Delete extra file from server: " + existingServerFile.FullName);
So, without a look at your code, and a log that shows this to be happening, there will be no further analysis of this issue.
Here's my log, and this is the relevant part of the code:
FtpClient client = new FtpClient(host, username, password);
client.Logger = new FtpLogAdapter(logger);
client.AutoConnect();
ftpResults = client.UploadDirectory(sourcePath, remotePath, FtpFolderSyncMode.Mirror, FtpRemoteExists.Overwrite, FtpVerify.None);
client.AutoDispose();
The only actual extra files were "AAA New Text Document.txt" and "ZZZ/New Text Document.txt", but it identified them all as Extra (after uploading them) and so deleted them.
I have not been able to reproduce this. Anyone else experiencing this problem?
I'm sorry you encountered this edge case failure with the Mirror mode. I confess Mirror mode was not extensively tested. That being said, Update mode will be safer for you at this stage. The main difference between Mirror and Update is the deletion of "extra files".
I had the same issue occur today. I have been using Update mode with no problems but tried using Mirror mode for the first time. The upload folder operation results reported that it skipped 16 files, no errors, but in fact it deleted the 16 files that were already in the target upload folder. Sorry but I don't have logs at this time.
@BrianCook Nice to hear this confirmation. Very valuable.
Sorry but I don't have logs at this time.
Ok.