Skip to content

Commit

Permalink
Fix setting redis db path (go-gitea#15698)
Browse files Browse the repository at this point in the history
Backport go-gitea#15698

There is a bug setting the redis db in the common nosql manager whereby the db path
always fails.

This PR fixes this.

Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath committed May 3, 2021
1 parent cead819 commit d904f7d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/nosql/manager_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (m *Manager) GetRedisClient(connection string) redis.UniversalClient {
opts.Addrs = append(opts.Addrs, strings.Split(uri.Host, ",")...)
}
if uri.Path != "" {
if db, err := strconv.Atoi(uri.Path); err == nil {
if db, err := strconv.Atoi(uri.Path[1:]); err == nil {
opts.DB = db
}
}
Expand All @@ -168,7 +168,7 @@ func (m *Manager) GetRedisClient(connection string) redis.UniversalClient {
opts.Addrs = append(opts.Addrs, strings.Split(uri.Host, ",")...)
}
if uri.Path != "" {
if db, err := strconv.Atoi(uri.Path); err == nil {
if db, err := strconv.Atoi(uri.Path[1:]); err == nil {
opts.DB = db
}
}
Expand All @@ -186,7 +186,7 @@ func (m *Manager) GetRedisClient(connection string) redis.UniversalClient {
opts.Addrs = append(opts.Addrs, strings.Split(uri.Host, ",")...)
}
if uri.Path != "" {
if db, err := strconv.Atoi(uri.Path); err == nil {
if db, err := strconv.Atoi(uri.Path[1:]); err == nil {
opts.DB = db
}
}
Expand Down

0 comments on commit d904f7d

Please sign in to comment.