Skip to content

Commit

Permalink
simplify seek/read check
Browse files Browse the repository at this point in the history
  • Loading branch information
funkyshu committed Feb 1, 2024
1 parent a11e952 commit e9cf2e5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions backend/os/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ func (f *File) copyToLocalTempReader() (*os.File, error) {
// So imagine we have a file with content "hello world" and we call Seek(6, 0) and then Write([]byte("there")), the
// temp file should have "hello there" and not "there". Then finally when Close is called, the temp file is renamed
// to the original file. This code ensures that scenario works as expected.
if exists {
if exists && (f.seekCalled || f.readCalled) {
openFunc := openOSFile
if f.fileOpener != nil {
openFunc = f.fileOpener
Expand All @@ -467,10 +467,8 @@ func (f *File) copyToLocalTempReader() (*os.File, error) {
if err != nil {
return nil, err
}
if f.seekCalled || f.readCalled {
if _, err := io.Copy(tmpFile, actualFile); err != nil {
return nil, err
}
if _, err := io.Copy(tmpFile, actualFile); err != nil {
return nil, err
}

if f.cursorPos > 0 {
Expand Down

0 comments on commit e9cf2e5

Please sign in to comment.