(t *Transfer, workerNum int, cb ProgressCallback)
| 186 | } |
| 187 | |
| 188 | func (a *SSHAdapter) download(t *Transfer, workerNum int, cb ProgressCallback) error { |
| 189 | rel, err := t.Rel("download") |
| 190 | if err != nil { |
| 191 | return err |
| 192 | } |
| 193 | if rel == nil { |
| 194 | return errors.New(tr.Tr.Get("No download action for object: %s", t.Oid)) |
| 195 | } |
| 196 | // Reserve a temporary filename. We need to make sure nobody operates on the file simultaneously with us. |
| 197 | f, err := tools.TempFile(a.tempDir(), t.Oid, a.fs) |
| 198 | if err != nil { |
| 199 | return err |
| 200 | } |
| 201 | tmpName := f.Name() |
| 202 | defer func() { |
| 203 | if f != nil { |
| 204 | f.Close() |
| 205 | } |
| 206 | os.Remove(tmpName) |
| 207 | }() |
| 208 | |
| 209 | return a.doDownload(t, workerNum, f, cb) |
| 210 | } |
| 211 | |
| 212 | // doDownload starts a download. f is expected to be an existing file open in RW mode |
| 213 | func (a *SSHAdapter) doDownload(t *Transfer, workerNum int, f *os.File, cb ProgressCallback) error { |
no test coverage detected