Skip to content

Commit

Permalink
Clean up temp file
Browse files Browse the repository at this point in the history
  • Loading branch information
benpate committed Nov 24, 2024
1 parent cd834df commit cde0e6f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions service/streamArchive.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ func (service *StreamArchive) Create(stream *model.Stream, options StreamArchive
return derp.Wrap(err, location, "Error creating ZIP archive")
}

// If we fail creating or moving the temp file, then try to delete it.
defer func() {
if err := service.exportCache.Remove(tempFilename); err != nil {
derp.Report(derp.Wrap(err, location, "Error deleting temp file"))
}
}()

// Move the temp file to the permanent location
if err := service.exportCache.Rename(tempFilename, filename); err != nil {
return derp.Wrap(err, location, "Error moving temp file into place")
Expand Down

0 comments on commit cde0e6f

Please sign in to comment.