From d1a96c25438e1e63c9e2caf77005ae86da14fc72 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 25 Jun 2017 01:16:32 -0400 Subject: [PATCH] cmd/restore: skip non existent directories in backup archive (#4413) --- cmd/restore.go | 8 +++++++- gogs.go | 2 +- templates/.VERSION | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/restore.go b/cmd/restore.go index 8e2d2d1f8..19c264641 100644 --- a/cmd/restore.go +++ b/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) } } diff --git a/gogs.go b/gogs.go index 141a65067..b3d839cb7 100644 --- a/gogs.go +++ b/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 diff --git a/templates/.VERSION b/templates/.VERSION index 9076ba81d..d91dbf212 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.11.22.0621 \ No newline at end of file +0.11.23.0625 \ No newline at end of file