Browse Source

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

pull/4584/head
Unknwon 8 years ago
parent
commit
d1a96c2543
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 8
      cmd/restore.go
  2. 2
      gogs.go
  3. 2
      templates/.VERSION

8
cmd/restore.go

@ -103,13 +103,19 @@ func runRestore(c *cli.Context) error {
if !c.Bool("database-only") { if !c.Bool("database-only") {
os.MkdirAll(setting.AppDataPath, os.ModePerm) os.MkdirAll(setting.AppDataPath, os.ModePerm)
for _, dir := range []string{"attachments", "avatars"} { 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) dirPath := path.Join(setting.AppDataPath, dir)
if com.IsExist(dirPath) { if com.IsExist(dirPath) {
if err = os.Rename(dirPath, dirPath+".bak"); err != nil { if err = os.Rename(dirPath, dirPath+".bak"); err != nil {
log.Fatal(0, "Fail to backup current 'data': %v", err) 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) log.Fatal(0, "Fail to import 'data': %v", err)
} }
} }

2
gogs.go

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

2
templates/.VERSION

@ -1 +1 @@
0.11.22.0621 0.11.23.0625
Loading…
Cancel
Save