Skip to content

Commit

Permalink
fix: compatible when the INFO command is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny-craft committed Aug 7, 2024
1 parent 868b0c8 commit a14e7e9
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions backend/services/browser_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,27 @@ 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"]
var db, maxDB int
for dbName := range keyspace {
if db, err = strconv.Atoi(strings.TrimLeft(dbName, "db")); err == nil {
if maxDB < db {
maxDB = db
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 {
if maxDB < db {
maxDB = db
}
}
}
totaldb = maxDB + 1
}
totaldb = maxDB + 1
}

queryDB := func(idx int) types.ConnectionDB {
Expand Down

0 comments on commit a14e7e9

Please sign in to comment.