fix: correctly close the db file in v4/v5 stores (#2066)

Signed-off-by: Andrei Stefanie <andrei.stefanie@gmail.com>
This commit is contained in:
Andrei Stefanie 2024-08-19 18:51:59 +03:00 committed by GitHub
parent 7dfa436314
commit 589d86c35a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View file

@ -265,8 +265,8 @@ func (s *store) AddVulnerabilityMatchExclusion(exclusions ...v4.VulnerabilityMat
func (s *store) Close() {
s.db.Exec("VACUUM;")
sqlDB, err := s.db.DB()
if err != nil {
sqlDB, _ := s.db.DB()
if sqlDB != nil {
_ = sqlDB.Close()
}
}

View file

@ -289,8 +289,8 @@ func (s *store) AddVulnerabilityMatchExclusion(exclusions ...v5.VulnerabilityMat
func (s *store) Close() {
s.db.Exec("VACUUM;")
sqlDB, err := s.db.DB()
if err != nil {
sqlDB, _ := s.db.DB()
if sqlDB != nil {
_ = sqlDB.Close()
}
}