Merge remote-tracking branch 'origin/master'

pull/1626/head
HFO4 2 years ago
commit ffbafca994

@ -43,11 +43,20 @@ func Init() {
conf.DatabaseConfig.Name, conf.DatabaseConfig.Name,
conf.DatabaseConfig.Port)) conf.DatabaseConfig.Port))
case "mysql", "mssql": case "mysql", "mssql":
db, err = gorm.Open(conf.DatabaseConfig.Type, fmt.Sprintf("%s:%s@(%s:%d)/%s?charset=%s&parseTime=True&loc=Local", var host string
if conf.DatabaseConfig.UnixSocket {
host = fmt.Sprintf("unix(%s)",
conf.DatabaseConfig.Host)
} else {
host = fmt.Sprintf("(%s:%d)",
conf.DatabaseConfig.Host,
conf.DatabaseConfig.Port)
}
db, err = gorm.Open(conf.DatabaseConfig.Type, fmt.Sprintf("%s:%s@%s/%s?charset=%s&parseTime=True&loc=Local",
conf.DatabaseConfig.User, conf.DatabaseConfig.User,
conf.DatabaseConfig.Password, conf.DatabaseConfig.Password,
conf.DatabaseConfig.Host, host,
conf.DatabaseConfig.Port,
conf.DatabaseConfig.Name, conf.DatabaseConfig.Name,
conf.DatabaseConfig.Charset)) conf.DatabaseConfig.Charset))
default: default:

@ -17,6 +17,7 @@ type database struct {
DBFile string DBFile string
Port int Port int
Charset string Charset string
UnixSocket bool
} }
// system 系统通用配置 // system 系统通用配置

@ -10,10 +10,11 @@ var RedisConfig = &redis{
// DatabaseConfig 数据库配置 // DatabaseConfig 数据库配置
var DatabaseConfig = &database{ var DatabaseConfig = &database{
Type: "UNSET", Type: "UNSET",
Charset: "utf8", Charset: "utf8",
DBFile: "cloudreve.db", DBFile: "cloudreve.db",
Port: 3306, Port: 3306,
UnixSocket: false,
} }
// SystemConfig 系统公用配置 // SystemConfig 系统公用配置

Loading…
Cancel
Save