0

I searched the Internet about the problem with file being uploaded on the FTP, no locking mechanism what results in not knowing if file that FTP client want to get is being uploaded.

Main articles that I found concerned about changing configuration of FTP server or getting files only when some time passed after last modification date: How to detect that a file is being uploaded over FTP (only guettli suggested using STAT command) https://community.boomi.com/s/article/ftpfilelockinghowtoavoidpickinguppartialorincompletefilesfromftpsftpsite

I want to use poller mechanism on FTP server that I do not have permission to administrate so I want to know if file which is being uploaded or appended. In FTP there is STAT [file] command that returns the status of the file, which exactly executes LIST [file] to get status code from FTP server. Can I rely on this command? And why using this command was not suggested in any article?

  • What does it mean *"guarantee proper status"* – Anyway, there are no guarantees in FTP. FTP is decades old protocol, designed in times, when specifications were vague and the implementations are consequently vague too. – Martin Prikryl Apr 07 '20 at 12:31
  • Guarantee means that I can be sure if file is locked or is not locked but currently in use by other process, so I receive negative status. By negative I mean from negative statuses groups described here: https://en.wikipedia.org/wiki/List_of_FTP_server_return_codes – Ferdynand Kiepski Apr 07 '20 at 12:37
  • I do not think you get *"negative"* status when you use `STAT` command on a locked file. It's generally possible to retrieve attributes of a locked file. Nothing prevents you from doing `ls file` or `dir file` on a locked file. But of course it all depends on particular FTP server implementation. – Martin Prikryl Apr 07 '20 at 12:40
  • Even if you could get definitive indication of whether or not a file has stopped being uploaded, that information is almost useless because you have no way of knowing if the entire file was actually transferred fully. The only one who knows that is the sender. If you want your system to work to a higher standard than "I **HOPE** this file is complete", the sender must send a signal of some sort to indicate that the entire file was successfully transferred, such as something like renaming the file or sending an empty `filename.done` file. Files are not messaging systems. – Andrew Henle Apr 07 '20 at 14:55

0 Answers0