cmd/restore: skip non existent directories in backup archive (#4413)

pull/4584/head
Unknwon 2017-06-25 01:16:32 -04:00
parent 11b1498a6e
commit d1a96c2543
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
3 changed files with 9 additions and 3 deletions

View File

@ -103,13 +103,19 @@ func runRestore(c *cli.Context) error {
if !c.Bool("database-only") {
os.MkdirAll(setting.AppDataPath, os.ModePerm)
for _, dir := range []string{"attachments", "avatars"} {
// Skip if backup archive does not have corresponding data
srcPath := path.Join(archivePath, "data", dir)
if !com.IsDir(srcPath) {
continue
}
dirPath := path.Join(setting.AppDataPath, dir)
if com.IsExist(dirPath) {
if err = os.Rename(dirPath, dirPath+".bak"); err != nil {
log.Fatal(0, "Fail to backup current 'data': %v", err)
}
}
if err = os.Rename(path.Join(archivePath, "data", dir), dirPath); err != nil {
if err = os.Rename(srcPath, dirPath); err != nil {
log.Fatal(0, "Fail to import 'data': %v", err)
}
}

View File

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/pkg/setting"
)
const APP_VER = "0.11.22.0621"
const APP_VER = "0.11.23.0625"
func init() {
setting.AppVer = APP_VER

View File

@ -1 +1 @@
0.11.22.0621
0.11.23.0625