mirror of https://github.com/pkg/sftp.git
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:
parent
3c6b3a4ff1
commit
1bc3ea14d1
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue