* sftp: honor the CREATE, EXCL and APPEND open flags
An upload open ignored three of its flags:
- Without CREATE, opening a missing file created it on close. It now fails
with NO_SUCH_FILE, as OpenSSH's sftp-server and SFTPGo do.
- CREATE|EXCL on an existing file succeeded and overwrote it. The open now
creates the empty file with an exclusive filer create, so it fails when
the name is taken, also while another exclusive upload of it buffers.
- APPEND wrote at the client's offset, usually 0, over the start of the
file. A write below the size the file had at open is now refused, as
SFTPGo does. Writes keep their offsets rather than going to the current
end, because pkg/sftp may run a client's pipelined writes in any order.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sftp: leave a file alone when an open of it changes nothing
An APPEND open whose writes were all refused still uploaded the copied
bytes on close, which rewrote the file and handed it to the session's
user. Any open that copied the existing file now uploads only once the
handle writes or sets attributes, not only read-write opens.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Denis Maier <denis@dAir.lab>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>