Skip to content

Commit

Permalink
fix(pkg/dabase): return error when attempting to access deleted database
Browse files Browse the repository at this point in the history
Signed-off-by: Stefano Scafiti <stefano.scafiti96@gmail.com>
  • Loading branch information
ostafen committed Sep 16, 2024
1 parent d47d3ef commit 0f6296b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/database/db_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,15 @@ func (m *DBManager) Has(name string) bool {
}

func (m *DBManager) HasIndex(idx int) bool {
m.dbMutex.RLock()
defer m.dbMutex.RUnlock()
db, exists := m.getDB(idx)
if !exists {
return false
}

db.mtx.Lock()
defer db.mtx.Unlock()

return idx >= 0 && idx < len(m.databases)
return !db.deleted
}

func (m *DBManager) GetIndexByName(name string) int {
Expand Down

0 comments on commit 0f6296b

Please sign in to comment.