Goldstein Lyor commented on SSHD-108:

As previously explained, there is no standard way the server can detect an 
"abort" from the client. If the client simply stops reading then it is 
indistinguishable from an "abort" (at least until the connection is broken). 
That being said, using a registered {{SftpEventListener}} in conjunction with a 
{{SessionListener}} enables *tracking* I/O operations on files (including 
read/write) and with some smart coding one could detect the fact that a file 
has been closed before it was fully read. The tracking code is not trivial, but 
possible by using these listeners.

Specifically have a look at the following {{SftpEventListener}} methods which I 
believe I would use if I were to implement such a feature:

* {{initialized}} - initialize the tracking mechanism for the session
* {{destroying}} - see which files are incomplete
* {{open}}, {{read}}, {{reading}} - track the reading process (make sure you 
are tracking only *files* since {{open}} is also called for directories)
* {{close}} - see if entire file has been read

BTW, if indeed you are able to implement it, please consider contributing the 
code the project via a pull request - preferably under the _sshd-contrib_ 

P.S. in version 1.3 (soon to be released) the listener API has been augmented 
to include more information and facilitate even further this functionality.

> Add upload monitoring to sftp
> -----------------------------
>                 Key: SSHD-108
>                 URL: https://issues.apache.org/jira/browse/SSHD-108
>             Project: MINA SSHD
>          Issue Type: Improvement
>    Affects Versions: 0.5.0
>            Reporter: Richard Evans
>            Assignee: Goldstein Lyor
>            Priority: Minor
>             Fix For: 1.1.0
> We have sshd integrated into our application and sftp is working fine.  One 
> of the requirements is to initiate some action when a file upload it 
> complete.  I have made this work by implementing handleClose in my SshFile 
> implementation and performing the action if createOutputStream had been 
> called previously.  This seems a bit ugly though; it might be nicer if there 
> was some plug in mechanism to monitor file transfers.
> Ideally the monitor would be able to distinguish between a successful upload 
> and a cancelled one (via ctrl-c at the client), but a quick perusal of the 
> sftp stuff seems to inidicate that this is not possible. 

This message was sent by Atlassian JIRA

Reply via email to