Skip to content

Commit

Permalink
dhcpsvc: close db
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Jul 9, 2024
1 parent d08b709 commit 064d4aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions internal/dhcpsvc/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/dhcpsvc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 064d4aa

Please sign in to comment.