Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: close tmp file #1082

Closed
wants to merge 1 commit into from
Closed

Conversation

testwill
Copy link
Contributor

@testwill testwill commented Apr 26, 2024

Solved issues and/or description of the change

Closing the file before removing it will prevent problems, e.g. see:
https://stackoverflow.com/questions/63519526/should-i-close-os-file-before-calling-os-removeall

Manual test

none

Checklist

  • The PR's target branch is 'hybridgroup:dev'
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (e.g. by run make test_race)
  • No linter errors exist locally (e.g. by run make fmt_check)
  • I have performed a self-review of my own code

@@ -149,6 +149,7 @@ func (fs *MockFilesystem) stat(name string) (os.FileInfo, error) {
log.Println("A")
return nil, err
}
defer tmpFile.Close()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
defer tmpFile.Close()
defer func() {
tmpFile.Close()
os.Remove(tmpFile.Name())
}()

and remove line 153 (I'm not able to mark both lines for the suggestion)

@gen2thomas
Copy link
Collaborator

Hi @testwill , thanks for finding and fix. Please change the target branch to "dev" according our PR policy and fill the checklist.

@gen2thomas
Copy link
Collaborator

Hi @testwill , I take over this fix and set this PR to draft.

@gen2thomas
Copy link
Collaborator

Hi @testwill , I have merged the changes together with #1091 . Thanks for finding and your provided PR.

@gen2thomas gen2thomas closed this Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants