Event handlers for, e.g., on file receive ... #757
Replies: 2 comments 1 reply
-
You could implement something which tracks file open and close calls, recording the filename in the open along with a file handle, and later on close you could map the file handle back to the filename. However, there's no guarantee that whole files will be written in a single open/close call, so it might be difficult to know whether you have a complete file or not. You could track write calls to see exactly what data is written where, but this data could arrive out of order, and not all of the file would need to be updated. Some data could be left over from previous opens of the file. |
Beta Was this translation helpful? Give feedback.
-
Any comparison of file data on the two sides would have to be done as a layer on top of SFTP, like what 'rsync' does. The SFTP protocol itself just provides calls to read or write byte ranges within a file, and other things like directory management. It doesn't operate on complete files. In your open function, you could detect whether something is a new file or not, and you could later detect when the file was closed. If the file didn't previously exist, you could assume that what ends up in the file at close is complete. This may not always be the case, but it would be the common case. Similarly, even if the file does exist, you could choose to treat any modified file as a new file at close, even if it contained a mix of old & new data. It all depends on what you want to do once you have these files. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there, I just wanted to ask, I can't see a reference for them in the documentation, but there is a lot of it, and I'm not sure what I would be looking for ... but is there any way to implement a "on file receive" callback at all?
Beta Was this translation helpful? Give feedback.
All reactions