Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastXfer: Transferring 0 byte file #179

Open
BitStream1 opened this issue Sep 28, 2021 · 0 comments
Open

fastXfer: Transferring 0 byte file #179

BitStream1 opened this issue Sep 28, 2021 · 0 comments

Comments

@BitStream1
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant