mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Modify: move aria2 into internal packages / migration version check
This commit is contained in:
@@ -72,11 +72,39 @@ type cors struct {
|
||||
|
||||
var cfg *ini.File
|
||||
|
||||
const defaultConf = `
|
||||
[System]
|
||||
Mode = master
|
||||
Listen = :5212
|
||||
SessionSecret = {SessionSecret}
|
||||
HashIDSalt = {HashIDSalt}
|
||||
`
|
||||
|
||||
// Init 初始化配置文件
|
||||
func Init(path string) {
|
||||
var err error
|
||||
//TODO 配置文件不存在时创建
|
||||
//TODO 配置合法性验证
|
||||
|
||||
if path == "" || !util.Exists(path) {
|
||||
// 创建初始配置文件
|
||||
confContent := util.Replace(map[string]string{
|
||||
"{SessionSecret}": util.RandStringRunes(64),
|
||||
"{HashIDSalt}": util.RandStringRunes(64),
|
||||
}, defaultConf)
|
||||
f, err := util.CreatNestedFile("conf.ini")
|
||||
if err != nil {
|
||||
util.Log().Panic("无法创建配置文件, %s", err)
|
||||
}
|
||||
|
||||
// 写入配置文件
|
||||
_, err = f.WriteString(confContent)
|
||||
if err != nil {
|
||||
util.Log().Panic("无法写入配置文件, %s", err)
|
||||
}
|
||||
|
||||
f.Close()
|
||||
path = "conf.ini"
|
||||
}
|
||||
|
||||
cfg, err = ini.Load(path)
|
||||
if err != nil {
|
||||
util.Log().Panic("无法解析配置文件 '%s': %s", path, err)
|
||||
|
||||
@@ -18,7 +18,7 @@ var DatabaseConfig = &database{
|
||||
var SystemConfig = &system{
|
||||
Debug: false,
|
||||
Mode: "master",
|
||||
Listen: ":5000",
|
||||
Listen: ":5212",
|
||||
}
|
||||
|
||||
// CaptchaConfig 验证码配置
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
package conf
|
||||
|
||||
import "io/ioutil"
|
||||
// BackendVersion 当前后端版本号
|
||||
const BackendVersion = string("3.0.0-beta1")
|
||||
|
||||
// 当前后端版本号
|
||||
const BackendVersion = string("3.0.0-b")
|
||||
|
||||
// WriteVersionLock 将当前版本信息写入 version.lock
|
||||
func WriteVersionLock() error {
|
||||
err := ioutil.WriteFile("version.lock", []byte(BackendVersion), 0644)
|
||||
return err
|
||||
}
|
||||
// RequiredDBVersion 与当前版本匹配的数据库版本
|
||||
const RequiredDBVersion = string("3.0.0-beta1")
|
||||
|
||||
Reference in New Issue
Block a user