C2FO / vfs

Pluggable, extensible virtual file system for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Only open sftp file as RW when Write'ing after a read action (Read or Seek)

funkyshu opened this issue · comments

Describe the bug
When doing only Write actions in SFTP backend, we unnecessarily open files as os.O_RDWR. This causes issues if the location you're connecting to provides only write access, no read.

Expected behavior
The only time we need RW is when we write after a read action (Read or Seek). Otherwise a Write should open files as os.O_WRONLY.

Additional context
Currently, a Write to a directly that has insufficient permissions returns "write error: file not found".