fix: no db loaded (#353)

This commit is contained in:
Lykin 2024-09-25 14:40:43 +08:00
parent a70b5b56ff
commit 026591c8d4
1 changed files with 7 additions and 8 deletions

View File

@ -166,17 +166,16 @@ func (b *browserService) OpenConnection(name string) (resp types.JSResp) {
if totaldb <= 0 { if totaldb <= 0 {
// cannot retrieve the database count by "CONFIG GET databases", try to get max index from keyspace // cannot retrieve the database count by "CONFIG GET databases", try to get max index from keyspace
if keyspace := info["Keyspace"]; len(keyspace) > 0 { keyspace := info["Keyspace"]
var db, maxDB int var db, maxDB int
for dbName := range keyspace { for dbName := range keyspace {
if db, err = strconv.Atoi(strings.TrimLeft(dbName, "db")); err == nil { if db, err = strconv.Atoi(strings.TrimLeft(dbName, "db")); err == nil {
if maxDB < db { if maxDB < db {
maxDB = db maxDB = db
}
} }
} }
totaldb = maxDB + 1
} }
totaldb = maxDB + 1
} }
queryDB := func(idx int) types.ConnectionDB { queryDB := func(idx int) types.ConnectionDB {