]> source.dussan.org Git - gitea.git/commitdiff
Fix setting redis db path (#15698)
authorzeripath <art27@cantab.net>
Mon, 3 May 2021 17:24:24 +0000 (18:24 +0100)
committerGitHub <noreply@github.com>
Mon, 3 May 2021 17:24:24 +0000 (13:24 -0400)
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 <art27@cantab.net>
modules/nosql/manager_redis.go

index d754a0e07d9cb71f8f0745e652571228dcdd289d..b4852cecc849e281e610362250f1b0d97e90ace9 100644 (file)
@@ -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
                        }
                }
@@ -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
                        }
                }
@@ -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
                        }
                }