This commit is contained in:
hoteas 2019-09-03 03:55:05 +00:00
parent c301928815
commit f4c59d56e2
1 changed files with 3 additions and 13 deletions

View File

@ -224,17 +224,7 @@ func (this *Application) SetConfig(configPath ...string) {
log.Println("配置文件不存在,或者配置出错,使用缺省默认配置")
}
//else {
// //文件不存在则写入文件,存在不做处理
// var out bytes.Buffer
// err = json.Indent(&out, []byte(this.Config.ToJsonString()), "", "\t")
// os.MkdirAll(filepath.Dir(this.configPath), os.ModeDir)
// os.Create(this.configPath)
// err = ioutil.WriteFile(this.configPath, out.Bytes(), os.ModeApplicationend)
// if err != nil {
// this.Error.SetError(err)
// }
//}
//文件如果损坏则不写入配置防止配置文件数据丢失
if this.Error.GetError() == nil {
var out bytes.Buffer
@ -245,6 +235,8 @@ func (this *Application) SetConfig(configPath ...string) {
if len(btes)!=0&&out.String()==string(btes){
return
}
err = ioutil.WriteFile(this.configPath, out.Bytes(), os.ModeAppend)
if err != nil {
@ -257,8 +249,6 @@ func (this *Application) SetConfig(configPath ...string) {
}
}
} else {
this.Error.SetError(nil)
}
}