fix(defrag): close temp file in case of error
Signed-off-by: Thomas Gosteli <thomas.gosteli@protonmail.ch>
This commit is contained in:
@ -499,6 +499,15 @@ func (b *backend) defrag() error {
|
|||||||
tdbp := temp.Name()
|
tdbp := temp.Name()
|
||||||
tmpdb, err := bolt.Open(tdbp, 0600, &options)
|
tmpdb, err := bolt.Open(tdbp, 0600, &options)
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user