Skip to content

Commit

Permalink
Add missing file.Close() for bdb and ndb (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinroh authored Sep 12, 2023
1 parent 067d98b commit bd1c2e6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/bdb/bdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func Open(path string) (*BerkeleyDB, error) {
}, nil
}

func (db *BerkeleyDB) Close() error {
return db.file.Close()
}

func (db *BerkeleyDB) Read() <-chan dbi.Entry {
entries := make(chan dbi.Entry)

Expand Down
1 change: 1 addition & 0 deletions pkg/db/rpmdbinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ type Entry struct {

type RpmDBInterface interface {
Read() <-chan Entry
Close() error
}
4 changes: 4 additions & 0 deletions pkg/ndb/ndb.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ func Open(path string) (*RpmNDB, error) {
}, nil
}

func (db *RpmNDB) Close() error {
return db.file.Close()
}

func (db *RpmNDB) Read() <-chan dbi.Entry {
entries := make(chan dbi.Entry)

Expand Down
4 changes: 4 additions & 0 deletions pkg/rpmdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func Open(path string) (*RpmDB, error) {

}

func (d *RpmDB) Close() error {
return d.db.Close()
}

func (d *RpmDB) Package(name string) (*PackageInfo, error) {
pkgs, err := d.ListPackages()
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/rpmdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,9 @@ func TestRpmDB_Package(t *testing.T) {
got.GroupNames = nil

assert.Equal(t, tt.want, got)

err = db.Close()
require.NoError(t, err)
})
}
}

0 comments on commit bd1c2e6

Please sign in to comment.