mirror of https://github.com/gogs/gogs.git
cmd/restore: skip non existent directories in backup archive (#4413)
parent
11b1498a6e
commit
d1a96c2543
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
2
gogs.go
2
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 @@
|
|||
0.11.22.0621
|
||||
0.11.23.0625
|
Loading…
Reference in New Issue