-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
Race-condition when renaming a file after upload #6
Comments
This is an issue in FluentFTP. I'm working on this. The error is because the data stream used for writing the file is parallel to the FTP control stream. I need to find a way to delay the control stream so race conditions don't occur. I'll be adding the alt version in another API, probably called |
I have fixed this in 16.0.17 if you use the high level UploadFile and DownloadFile API. This is the code I used to test: static void TestUploadDownloadFile() {
using (FtpClient cl = new FtpClient()) {
cl.Host = m_host;
cl.Credentials = new NetworkCredential(m_user, m_pass);
// 10 M file
cl.UploadFile(@"D:\bigfile.exe", "/public_html/temp/big.txt");
cl.Rename("/public_html/temp/big.txt", "/public_html/temp/big2.txt");
cl.DownloadFile(@"D:\bigfile_2.exe", "/public_html/temp/big2.txt");
}
} Please check with the latest version and see if it solves your problem. |
Hi @hgupta9, Can I do anything to shorten the delay? I have also tried disconnecting and reconnecting, in this case the disconnect is delayed. Once reconnected the rename is instantaneous. |
Can you please add a separate issue for this as I see no connection with the OP's issue. And if you can use my code as a reference instead of coding from scratch; basically I upload in chunks, and various other stuff that might be useful and/or might solve your problem automatically. Please see UploadFileInternal |
Pull from upstream -- minor release 17.2.0
I'm not sure if this is a issue in FluentFTP or the FTP-server i'm using.
I'm uploading a file to a temporary filename to rename the file after the upload is complete.
This is because the folder i'm uploading to is periodically scanned by 3rd party software for certain files, and i need to prevent the 3rd party software to read partially completed uploads.
The following code causes the server to return error "Internal error renaming the file".
I'm guessing the issue is that the client wants to rename the uploaded file before the server thinks it's complete.
server log:
I can work around the problem by manually closing the control-connection for the file transfer.
server log:
The text was updated successfully, but these errors were encountered: