Skip to content

Commit

Permalink
fix(defrag): close temp file in case of error
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Gosteli <[email protected]>
  • Loading branch information
ghouscht committed Nov 7, 2024
1 parent 4ad9261 commit a19d408
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/storage/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,15 @@ func (b *backend) defrag() error {
tdbp := temp.Name()
tmpdb, err := bolt.Open(tdbp, 0600, &options)
if err != nil {
temp.Close()
if err := os.Remove(temp.Name()); err != nil && b.lg != nil {
b.lg.Error(
"failed to remove temporary file",
zap.String("path", temp.Name()),
zap.Error(err),
)
}

return err
}

Expand Down

0 comments on commit a19d408

Please sign in to comment.