pkg/sftp — pull request #31 by jblazquez (2014-12-19 01:45:16+00:00)
Title: Fixed write errors not bubbling up correctly

Errors returned by the SFTP server during a write operation were not being bubbled up correctly.

An easy way to repro is the following:

1. Create a tiny `tmpfs` filesystem:

```bash
mkdir /tmp/test
sudo mount -t tmpfs -o size=1M tmpfs /tmp/test
```

2. Try uploading a file larger than 1MB via SFTP:

```go
// Note: client is an *ssh.Client connected to localhost,
// /tmp/2M.bin is a 2MB file

ftp, err := sftp.NewClient(client)
if err != nil {
panic(err)
}

defer ftp.Close()

data, err := ioutil.ReadFile("/tmp/2M.bin")
if err != nil {
panic(err)
}

file, err := ftp.Create("/tmp/test/2M.bin")
if err != nil {
panic(err)
}

defer file.Close()

// BUG: This call blocks forever.
_, err = file.Write(data)
```