Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UploadDirectory in Mirror mode occasionally deletes destination folder's entire contents #1580

Open
AlienDave opened this issue May 24, 2024 · 9 comments

Comments

@AlienDave
Copy link

AlienDave commented May 24, 2024

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...

@FanDjango
Copy link
Collaborator

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.

@AlienDave
Copy link
Author

AlienDave commented May 25, 2024 via email

@FanDjango
Copy link
Collaborator

It uploaded the files, recorded them as successful in the FtpResults, THEN
deleted them.

Wow. Need to check the code how that can happen.

@FanDjango
Copy link
Collaborator

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.

@AlienDave
Copy link
Author

AlienDave commented May 27, 2024

FTP.log

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.

@FanDjango
Copy link
Collaborator

I have not been able to reproduce this. Anyone else experiencing this problem?

@robinrodricks
Copy link
Owner

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".

@BrianCook
Copy link

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.

@FanDjango
Copy link
Collaborator

@BrianCook Nice to hear this confirmation. Very valuable.

Sorry but I don't have logs at this time.

Ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants