Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How does FTP servers handle concurrent access to the same file, i.e. if one user is updating a file while another is reading the same file? Should I be worried about getting corrupt data? Is it dependent on the FTP server or even the operating system?

share|improve this question
add comment

5 Answers

I think the FTP Server itself does not handle this.
The underlying file-system will manage the accesses involved here.

If a read starts before a write, the read would typically get the older version.

You should get the answer to this question based on
the server file-system handling for a file being overwritten.

share|improve this answer
add comment

I think FTP implementations just don't deal with this, and the OS will vary on how it does, windows might lock the file, linux will give you partial data.

Yes you should be worried, specially under high usage. The solutions I found on the past were sketchy at best, including different folders for upload/download and a monitor process to copy from upload to download when the file is fully uploaded.

This gets worse as files are longer and/or people upload from slow connections.

share|improve this answer
add comment

I am pretty sure you could have problems. Try this:

Start a upload of a large file to your FTP server. Refresh the view of the folder it is being uploaded to and you will see that the file size increases and the upload progresses.

If you try this with a .mp3 file. You can access it via the browser and see that it will only play up to the point that is has currently been uploaded.

This is why programs like Dreamweaver have a check in/check out system. So that if someone is working on a .html file someone else cannot upload a older version or cause that sort of problems.

I don't think FTP uses any kind of temp files or queuing either...

share|improve this answer
    
Correct. I once unzipped a file that actually was not transferred all the way. Weird error messages, of course... –  Arjan Aug 20 '09 at 12:23
    
I think updating and existing file is different from creating a new file (the read will not start before the create happens, and then it will follow the write). If the read races-beyond the write, you get incompletely terminated reads. An incomplete ZIP file will show corruption. An incomplete mp3 will play up to the first point of corruption (i think). That is a difference in the file-formats. –  nik Aug 20 '09 at 13:28
    
A modify/overwrite of an existing file should identify a read-in-progress and create a new version-to-write, retaining the older one for the read to complete. That is why I say in my answer that a typical filesystem would give an older copy of the file in such a case. –  nik Aug 20 '09 at 13:32
add comment

Whenever I attempt to access a page I haven't uploaded yet, I get a "connection reset while loading". I think it's really up to the software, though.

share|improve this answer
add comment

Using a Revision Control Software would help in this case, have a look at Git and SVN, note that there is two main types (centralized and distributed) and many other applications in addition to those two.

share|improve this answer
    
This answer has nothing at all to do with the question... –  Kristian Sep 10 '11 at 17:25
    
Operations in those systems being atomic there is no way you could get an uncomplete file, problem solved. –  Shadok Sep 11 '11 at 1:21
    
Yes I know, but the question was specifically about FTP servers –  Kristian Sep 11 '11 at 20:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.