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 files in the toAgentSource func #4886

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

testwill
Copy link
Contributor

No description provided.

Signed-off-by: guoguangwu <guoguangwug@gmail.com>
@@ -166,6 +166,7 @@ func toAgentSource(paths []string) (source, error) {
return source{}, errors.Wrapf(err, "failed to open %s", p)
}
dt, err := io.ReadAll(&io.LimitedReader{R: f, N: 100 * 1024})
_ = f.Close()
Copy link
Collaborator

@profnandaa profnandaa Apr 26, 2024

Choose a reason for hiding this comment

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

nit: defer f.Close() is better? Right after the if-err block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it is in a for loop, I did not use defer f.Close()

@tonistiigi tonistiigi merged commit ca82a6d into moby:master Apr 26, 2024
73 checks passed
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.

None yet

3 participants