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: check close error in oci/storage.go during ingestion #830

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions content/oci/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,16 @@

path = fp.Name()
defer func() {
// remove the temp file in case of error.
// this executes after the file is closed.
// close the temp file and check close error
if err := fp.Close(); err != nil && ingestErr == nil {
ingestErr = fmt.Errorf("failed to close ingest file: %w", err)

Check warning on line 146 in content/oci/storage.go

View check run for this annotation

Codecov / codecov/patch

content/oci/storage.go#L146

Added line #L146 was not covered by tests
}

// remove the temp file in case of error
if ingestErr != nil {
os.Remove(path)
}
}()
defer fp.Close()

buf := bufPool.Get().(*[]byte)
defer bufPool.Put(buf)
Expand Down
Loading