fix issue with file put resume/append

Fixes issue with append uploads. Was opening the file with O_APPEND, but
it uses WriteAt() to write the data which doesn't work with a file
opened in append mode. Removing the append flag fixes the issue as the
client is sending the offsets anyways.

Also added a note to the Request server's FileWriter interface on
handling append flags.
This commit is contained in:
John Eikenberry 2020-01-02 14:33:58 -08:00
parent 3c6b3a4ff1
commit 1bc3ea14d1
2 changed files with 5 additions and 3 deletions

View File

@ -25,6 +25,8 @@ type FileReader interface {
// The request server code will call Close() on the returned io.WriterAt
// ojbect if an io.Closer type assertion succeeds.
// Note in cases of an error, the error text will be sent to the client.
// Note when receiving an Append flag it is important to not open files using
// O_APPEND if you plan to use WriteAt, as they conflict.
// Called for Methods: Put, Open
type FileWriter interface {
Filewrite(*Request) (io.WriterAt, error)

View File

@ -398,9 +398,9 @@ func (p sshFxpOpenPacket) respond(svr *Server) responsePacket {
return statusFromError(p, syscall.EINVAL)
}
if p.hasPflags(sshFxfAppend) {
osFlags |= os.O_APPEND
}
// Don't use O_APPEND flag as it conflicts with WriteAt.
// The sshFxfAppend flag is a no-op here as the client sends the offsets.
if p.hasPflags(sshFxfCreat) {
osFlags |= os.O_CREATE
}