-
Notifications
You must be signed in to change notification settings - Fork 140
Description
This is an absolutely awesome node ssh/sftp library. Thank you so much for your contribution! This is great!
I've just noticed that 0 byte files transferred using fastGet were hanging in an application I was working on, so I dug into it a bit:
In fastXfer(), I see:
if (fsize <= 0)
return onerror();
Should this not read:
if (fsize <= 0)
return cb();
e.g. onerror() should probably only be called with an error object, right. In the case of the file being zero bytes, this would also be the best point to finish by calling cb(). I'm guessing that this was what was meant, would that make sense? It does cure the problem in that 0 byte source files are handled ok with this change.
A suggestion - would it also make sense to export fastXfer() as a public API? I notice fastGet()/fastPut() are maybe 3-4x faster than e.g. createReadStream(), but they can only be used to/from the local machine. In the case where a transfer is over 2 sftp connections, fastXfer would be necessary, so it would be good to have in the public API for this reason.
Many thanks for your work on this. This is a great library!