sftpd: handle read and write from the same handle (#158)

Fixes #155
This commit is contained in:
Nicola Murino
2020-08-31 06:45:22 +02:00
committed by GitHub
parent 91a4c64390
commit 4748e6f54d
8 changed files with 209 additions and 58 deletions

View File

@@ -227,7 +227,7 @@ func (c *scpCommand) handleUploadFile(resolvedPath, filePath string, sizeToRead
baseTransfer := common.NewBaseTransfer(file, c.connection.BaseConnection, cancelFn, resolvedPath, requestPath,
common.TransferUpload, 0, initialSize, maxWriteSize, isNewFile, c.connection.Fs)
t := newTransfer(baseTransfer, w, nil)
t := newTransfer(baseTransfer, w, nil, nil)
return c.getUploadFileData(sizeToRead, t)
}
@@ -485,7 +485,7 @@ func (c *scpCommand) handleDownload(filePath string) error {
baseTransfer := common.NewBaseTransfer(file, c.connection.BaseConnection, cancelFn, p, filePath,
common.TransferDownload, 0, 0, 0, false, c.connection.Fs)
t := newTransfer(baseTransfer, nil, r)
t := newTransfer(baseTransfer, nil, r, nil)
err = c.sendDownloadFileData(p, stat, t)
// we need to call Close anyway and return close error if any and