pkg / sftp

SFTP support for the go.crypto/ssh package
BSD 2-Clause "Simplified" License
1.52k stars 380 forks source link

Notification that a file was closed by the SFTP client #473

Closed andy-retailnext closed 2 years ago

andy-retailnext commented 3 years ago

With the request-based API, the Close method on the object returned by Filewrite gets called whether the SFTP client actually sent a Close command or was interrupted during uploading and dropped the connection.

Is there some way to distinguish between these situations?

It is important for our use case that we avoid acting on files that were not fully uploaded by the client, so we need a way to know whether the client sent a SFTP Close command or if the Close on the object returned by Filewrite is due to another cause.

(We are currently using a fork of pkg/sftp from several years ago to which we have made several modifications, but now that the request based API is available, we want to use it instead of our fork. The request based API does almost everything we need, except for this ambiguity.)

If it is not currently possible to distinguish between these situations, would it be feasible for this library to utilize alternative/optional method(s) on the object returned by Filewrite to provide that information? (Or perhaps something could be added to Request that could be used to distinguish between the situations?)

drakkan commented 3 years ago

Hi,

this is already possible you have to implement the TransferError interface