Describe the bug
In case the file creation fails, NewWriter returns an object implementing io.WriteCloser instead of explicit error, misleading the user that the file creation succeeded.
f, err := os.Create(name)
if err != nil {
return &failWriter{err: err}
}
To Reproduce
Try to create a file in directory without write permission to the running user.
Expected behavior
Ideally NewWriter should return an explicit error. However, that would be a breaking change.
As a workaround, we could type check the response from NewWriter and if it matches failWriter, we return an error instead of considering it as success case in the following methods:
- func (c *CommonFileSystem) Mkdir(name string, _ os.FileMode) error
- func (c *CommonFileSystem) Create(name string) (File, error)
- func (c *CommonFileSystem) handleWriteFlags(name string, flag int) (File, error)
Describe the bug
In case the file creation fails, NewWriter returns an object implementing
io.WriteCloserinstead of explicit error, misleading the user that the file creation succeeded.To Reproduce
Try to create a file in directory without write permission to the running user.
Expected behavior
Ideally NewWriter should return an explicit error. However, that would be a breaking change.
As a workaround, we could type check the response from NewWriter and if it matches
failWriter, we return an error instead of considering it as success case in the following methods: