dhcpsvc: close db

This commit is contained in:
Eugene Burkov 2024-07-09 20:51:41 +03:00
parent d08b70983d
commit 064d4aa30b
2 changed files with 4 additions and 1 deletions

View file

@ -106,6 +106,9 @@ func (srv *DHCPServer) dbLoad(ctx context.Context) (err error) {
return nil return nil
} }
defer func() {
err = errors.WithDeferred(err, file.Close())
}()
dl := &dataLeases{} dl := &dataLeases{}
err = json.NewDecoder(file).Decode(dl) err = json.NewDecoder(file).Decode(dl)

View file

@ -20,7 +20,7 @@ import (
var testdata = os.DirFS("testdata") var testdata = os.DirFS("testdata")
// newTempDB copies the leases database file located in the testdata FS, under // newTempDB copies the leases database file located in the testdata FS, under
// tb.Name()/leases.db, to a temporary directory and returns the path to the // tb.Name()/leases.json, to a temporary directory and returns the path to the
// copied file. // copied file.
func newTempDB(tb testing.TB) (dst string) { func newTempDB(tb testing.TB) (dst string) {
tb.Helper() tb.Helper()