sftp icon indicating copy to clipboard operation
sftp copied to clipboard

sftp.File read error, cannot read file large than 16777216 (2^24)

Open fanan opened this issue 12 years ago • 4 comments

first, create a file larger than 2^24 byte

dd if=/dev/zero of=/tmp/zero.img bs=1M count=32

the golang code below demonstrates the bug:

// c is a sftp.Client

    rName := "/tmp/zero.img"

    fi, err := c.Lstat(rName)
    if err != nil {
        log.Fatal(err)
    }

    fp, err := c.Open(rName)
    if err != nil {
        log.Fatal(err)
    }
    defer fp.Close()

    n, err := io.Copy(ioutil.Discard, fp)
    if err != nil {
        log.Fatal(err)
    }
    if n != fi.Size() {
        log.Fatalf("copy %d != %d remote size", n, fi.Size())
    }

This means I cannot use the sftp package as a sftp client to get large files from the server.

fanan avatar May 23 '14 06:05 fanan

I think this might be the marshalUint64() bug. Does https://github.com/nemith/sftp/commit/6a6ba08f9e8eaaa485a98e836a9a34abbe39a102 fix your problem?

hochhaus avatar May 23 '14 13:05 hochhaus

Yes, that fixex my problem. Thank you.

fanan avatar May 25 '14 00:05 fanan

Thanks for looking into this, I'm sorry I've been absent on this package. I have some time set aside this weekend.

On 23/05/2014, at 23:47, hochhaus [email protected] wrote:

I think this might be the marshalUint64() bug. Does nemith@6a6ba08 fix your problem?

— Reply to this email directly or view it on GitHub.

davecheney avatar May 25 '14 00:05 davecheney

Closed by #7 via #4

davecheney avatar May 25 '14 04:05 davecheney