fix: compatible when the `INFO` command is unavailable
This commit is contained in:
parent
868b0c81b6
commit
a14e7e947e
|
@ -156,16 +156,17 @@ func (b *browserService) OpenConnection(name string) (resp types.JSResp) {
|
|||
} else {
|
||||
// get database info
|
||||
var res string
|
||||
res, err = client.Info(ctx, "keyspace").Result()
|
||||
if err != nil {
|
||||
resp.Msg = "get server info fail:" + err.Error()
|
||||
return
|
||||
info := map[string]map[string]string{}
|
||||
if res, err = client.Info(ctx, "keyspace").Result(); err != nil {
|
||||
//resp.Msg = "get server info fail:" + err.Error()
|
||||
//return
|
||||
} else {
|
||||
info = b.parseInfo(res)
|
||||
}
|
||||
info := b.parseInfo(res)
|
||||
|
||||
if totaldb <= 0 {
|
||||
// cannot retrieve the database count by "CONFIG GET databases", try to get max index from keyspace
|
||||
keyspace := info["Keyspace"]
|
||||
if keyspace := info["Keyspace"]; len(keyspace) > 0 {
|
||||
var db, maxDB int
|
||||
for dbName := range keyspace {
|
||||
if db, err = strconv.Atoi(strings.TrimLeft(dbName, "db")); err == nil {
|
||||
|
@ -176,6 +177,7 @@ func (b *browserService) OpenConnection(name string) (resp types.JSResp) {
|
|||
}
|
||||
totaldb = maxDB + 1
|
||||
}
|
||||
}
|
||||
|
||||
queryDB := func(idx int) types.ConnectionDB {
|
||||
dbName := "db" + strconv.Itoa(idx)
|
||||
|
|
Loading…
Reference in New Issue