I'm writing a shell script which would use inotify to monitor certain directories for incoming SFTP uploads. When a client is done uploading a file, the file would be handed over to another script which processes the file.
Now what happens if the network connection goes down in the mid of a transfer? As far as I understand openssh's sftp server, the file on the server would be closed, inotify would report a close event and my script would start to process the incomplete file.
This is obviously not what I want, so I need to tell complete and incomplete files apart.
Now my favorite way of doing this would be that either the sftp server or the client add an extension to the file name (e. g. .part or .filepart) to indicate that the file is incomplete. Once the transfer is confirmed to be complete, the extension would be removed.
Unfortunately, client behavior is not under my control, so the only way to implement the extension solution would be by implementing it on the server side.
Now is there some way how I can make the openssh sftp server add .part/.filepart extensions to incomplete files? Or is there some other way how I can tell whether a file is complete or not?