Skip to content

Commit

Permalink
update comments. Close some resources on Close(). Add CHANGELOG entry.
Browse files Browse the repository at this point in the history
  • Loading branch information
funkyshu committed Feb 14, 2024
1 parent a5bde45 commit cf0dd21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- Fixes #146 - Update S3 backend to comply with new io integration test suite. Update to no longer write to memory.
- Fixes #156 - Update os backend to comply with new io integration test suite
- Fixes #160 - Update mem backend to comply with new io integration test suite

Expand Down
14 changes: 13 additions & 1 deletion backend/s3/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,23 @@ func (f *File) Close() error {
if f.writeCalled && f.s3Writer != nil && f.s3WriterCompleteCh != nil {
// wait for s3Writer to complete
<-f.s3WriterCompleteCh
// close s3WriterCompleteCh channel
close(f.s3WriterCompleteCh)
}
err := waitUntilFileExists(f, 5)
if err != nil {
return err
}
}

// close reader
if f.reader != nil && !f.writeCalled {
err := f.reader.Close()
if err != nil {
return err
}
}

return nil
}

Expand Down Expand Up @@ -512,7 +522,7 @@ func (f *File) Touch() error {
}
} else {
// file already exists so update its last modified date
return utils.UpdateLastModifiedByMoving(f) // TODO: we should simply use CopyObject to copy the file to itself
return utils.UpdateLastModifiedByMoving(f)
}

return nil
Expand Down Expand Up @@ -692,6 +702,8 @@ func waitUntilFileExists(file vfs.File, retries int) error {
func (f *File) getReader() (io.ReadCloser, error) {
if f.reader == nil {
if f.writeCalled && f.tempFileWriter != nil {
// we've edited or truncated the file, so we need to read from the temp file which should already be at the
// current cursor position
f.reader = f.tempFileWriter
} else {
sz, err := f.Size()
Expand Down

0 comments on commit cf0dd21

Please sign in to comment.