Skip to content

Commit

Permalink
Clean up temp file when layout.WriteBlob errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-krieger committed Jan 6, 2022
1 parent 4ec656f commit 5965a6c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/v1/layout/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ func (l Path) writeBlob(hash v1.Hash, size int64, r io.Reader, renamer func() (v
if err != nil {
return err
}
if renamer != nil {
// Delete temp file if an error is encountered before renaming
defer os.Remove(w.Name())
}
defer w.Close()

// Write to file and exit if not renaming
Expand Down

0 comments on commit 5965a6c

Please sign in to comment.