pull/1037/head
不帅你报警 4 years ago
parent 990baf67f1
commit d1038c6764

@ -0,0 +1,3 @@
package global
var conf map[string]interface{}

@ -2,6 +2,7 @@ package conf
import ( import (
"github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/cloudreve/Cloudreve/v3/pkg/util"
"github.com/cloudreve/Cloudreve/v3/global"
"github.com/go-ini/ini" "github.com/go-ini/ini"
"gopkg.in/go-playground/validator.v9" "gopkg.in/go-playground/validator.v9"
) )
@ -148,6 +149,7 @@ func Init(path string) {
util.Log() util.Log()
} }
global.conf := sections
} }
// mapSection 将配置文件的 Section 映射到结构体上 // mapSection 将配置文件的 Section 映射到结构体上

@ -5,7 +5,7 @@ import (
"path" "path"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/cloudreve/Cloudreve/v3/pkg/conf" "github.com/cloudreve/Cloudreve/v3/global"
) )
// DotPathToStandardPath 将","分割的路径转换为标准路径 // DotPathToStandardPath 将","分割的路径转换为标准路径
@ -63,8 +63,9 @@ func RelativePath(name string) string {
if filepath.IsAbs(name) { if filepath.IsAbs(name) {
return name return name
} }
if conf.SystemConfig.DataPath != "" { SystemConfig, ok := global.conf[ "SystemConfig" ]
return filepath.Join(conf.SystemConfig.DataPath, name) if SystemConfig.DataPath != "" {
return filepath.Join(SystemConfig.DataPath, name)
} else { } else {
return RelativeExecutablePath(name) return RelativeExecutablePath(name)
} }

Loading…
Cancel
Save