Skip to content

fastXfer: Transferring 0 byte file #179

@BitStream1

Description

@BitStream1

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions