1
0
mirror of https://github.com/beego/bee.git synced 2024-11-23 01:30:55 +00:00

bak file err

This commit is contained in:
wangle 2020-07-24 15:15:29 +08:00
parent 5005bd4408
commit b4a1aec0e6

View File

@ -20,7 +20,7 @@ func (c *RenderFile) write(filename string, buf string) (err error) {
return return
} }
filePath := path.Dir(filename) filePath := filepath.Dir(filename)
err = createPath(filePath) err = createPath(filePath)
if err != nil { if err != nil {
err = errors.New("write create path " + err.Error()) err = errors.New("write create path " + err.Error())
@ -37,7 +37,7 @@ func (c *RenderFile) write(filename string, buf string) (err error) {
name := path.Base(filename) name := path.Base(filename)
if utils.IsExist(filename) { if utils.IsExist(filename) {
bakName := fmt.Sprintf("%s/%s.%s.bak", filePathBak, name, time.Now().Format("2006.01.02.15.04.05")) bakName := fmt.Sprintf("%s/%s.%s.bak", filePathBak, filepath.Base(name), time.Now().Format("2006.01.02.15.04.05"))
beeLogger.Log.Infof("bak file '%s'", bakName) beeLogger.Log.Infof("bak file '%s'", bakName)
if err := os.Rename(filename, bakName); err != nil { if err := os.Rename(filename, bakName); err != nil {
err = errors.New("file is bak error, path is " + bakName) err = errors.New("file is bak error, path is " + bakName)