mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: custom SQLite db file path
This commit is contained in:
@@ -30,7 +30,7 @@ func Init() {
|
|||||||
} else {
|
} else {
|
||||||
if conf.DatabaseConfig.Type == "UNSET" {
|
if conf.DatabaseConfig.Type == "UNSET" {
|
||||||
// 未指定数据库时,使用SQLite
|
// 未指定数据库时,使用SQLite
|
||||||
db, err = gorm.Open("sqlite3", util.RelativePath("cloudreve.db"))
|
db, err = gorm.Open("sqlite3", util.RelativePath(conf.DatabaseConfig.DBFile))
|
||||||
} else {
|
} else {
|
||||||
db, err = gorm.Open(conf.DatabaseConfig.Type, fmt.Sprintf("%s:%s@(%s)/%s?charset=utf8&parseTime=True&loc=Local",
|
db, err = gorm.Open(conf.DatabaseConfig.Type, fmt.Sprintf("%s:%s@(%s)/%s?charset=utf8&parseTime=True&loc=Local",
|
||||||
conf.DatabaseConfig.User,
|
conf.DatabaseConfig.User,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ type database struct {
|
|||||||
Host string
|
Host string
|
||||||
Name string
|
Name string
|
||||||
TablePrefix string
|
TablePrefix string
|
||||||
|
DBFile string
|
||||||
}
|
}
|
||||||
|
|
||||||
// system 系统通用配置
|
// system 系统通用配置
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ var RedisConfig = &redis{
|
|||||||
|
|
||||||
// DatabaseConfig 数据库配置
|
// DatabaseConfig 数据库配置
|
||||||
var DatabaseConfig = &database{
|
var DatabaseConfig = &database{
|
||||||
Type: "UNSET",
|
Type: "UNSET",
|
||||||
|
DBFile: "cloudreve.db",
|
||||||
}
|
}
|
||||||
|
|
||||||
// SystemConfig 系统公用配置
|
// SystemConfig 系统公用配置
|
||||||
|
|||||||
Reference in New Issue
Block a user