mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Fix: Redis should not be used in test mode
This commit is contained in:
@@ -14,8 +14,8 @@ var Store redis.Store
|
|||||||
|
|
||||||
// Session 初始化session
|
// Session 初始化session
|
||||||
func Session(secret string) gin.HandlerFunc {
|
func Session(secret string) gin.HandlerFunc {
|
||||||
if conf.RedisConfig.Server != "" {
|
// Redis设置不为空,且非测试模式时使用Redis
|
||||||
// 如果配置使用了Redis
|
if conf.RedisConfig.Server != "" && gin.Mode() == gin.TestMode {
|
||||||
var err error
|
var err error
|
||||||
Store, err = redis.NewStoreWithDB(10, "tcp", conf.RedisConfig.Server, conf.RedisConfig.Password, conf.RedisConfig.DB, []byte(secret))
|
Store, err = redis.NewStoreWithDB(10, "tcp", conf.RedisConfig.Server, conf.RedisConfig.Password, conf.RedisConfig.DB, []byte(secret))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user