Skip to content

Commit

Permalink
Merge pull request #18851 from ghouscht/issue-18841
Browse files Browse the repository at this point in the history
fix(defrag): close temp file in case of error
  • Loading branch information
ahrtr authored Nov 7, 2024
2 parents 1472b61 + a19d408 commit 694ace2
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 694ace2

Please sign in to comment.