Commit c2f7f3ef authored by astaxie's avatar astaxie Committed by GitHub

Merge pull request #2380 from fugr/config

config:fix handle include other.conf
parents 1e5051e1 3fa7fc6e
......@@ -54,10 +54,10 @@ func (ini *IniConfig) parseFile(name string) (*IniConfigContainer, error) {
return nil, err
}
return ini.parseData(data)
return ini.parseData(filepath.Dir(name), data)
}
func (ini *IniConfig) parseData(data []byte) (*IniConfigContainer, error) {
func (ini *IniConfig) parseData(dir string, data []byte) (*IniConfigContainer, error) {
cfg := &IniConfigContainer{
data: make(map[string]map[string]string),
sectionComment: make(map[string]string),
......@@ -135,10 +135,6 @@ func (ini *IniConfig) parseData(data []byte) (*IniConfigContainer, error) {
otherfile := strings.Trim(includefiles[1], "\"")
if !filepath.IsAbs(otherfile) {
dir, err := os.Getwd()
if err != nil {
return nil, err
}
otherfile = filepath.Join(dir, otherfile)
}
......@@ -187,8 +183,13 @@ func (ini *IniConfig) parseData(data []byte) (*IniConfigContainer, error) {
}
// ParseData parse ini the data
// When include other.conf,other.conf is either absolute directory
// or under beego in default temporary directory(/tmp/beego).
func (ini *IniConfig) ParseData(data []byte) (Configer, error) {
return ini.parseData(data)
dir := filepath.Join(os.TempDir(), "beego")
os.MkdirAll(dir, os.ModePerm)
return ini.parseData(dir, data)
}
// IniConfigContainer A Config represents the ini configuration.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment