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
}
defer func() {
err = errors.WithDeferred(err, file.Close())
}()
dl := &dataLeases{}
err = json.NewDecoder(file).Decode(dl)

View File

@ -20,7 +20,7 @@ import (
var testdata = os.DirFS("testdata")
// 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.
func newTempDB(tb testing.TB) (dst string) {
tb.Helper()