ソースを参照

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

Unknwon 7 年 前
コミット
d1a96c2543
3 ファイル変更9 行追加3 行削除
  1. 7 1
      cmd/restore.go
  2. 1 1
      gogs.go
  3. 1 1
      templates/.VERSION

+ 7 - 1
cmd/restore.go

@@ -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)
 			}
 		}

+ 1 - 1
gogs.go

@@ -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

+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.11.22.0621
+0.11.23.0625