bug fix for dump when data directoryis not exist (#1025) (#1100)

This commit is contained in:
Lunny Xiao 2017-03-16 09:23:12 +08:00 committed by GitHub
parent 3d1ff149a2
commit 53efbeadc1

View File

@ -17,6 +17,7 @@ import (
"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
"github.com/Unknwon/cae/zip" "github.com/Unknwon/cae/zip"
"github.com/Unknwon/com"
"github.com/urfave/cli" "github.com/urfave/cli"
) )
@ -100,17 +101,19 @@ func runDump(ctx *cli.Context) error {
log.Printf("Custom dir %s doesn't exist, skipped", setting.CustomPath) log.Printf("Custom dir %s doesn't exist, skipped", setting.CustomPath)
} }
log.Printf("Packing data directory...%s", setting.AppDataPath) if com.IsExist(setting.AppDataPath) {
var sessionAbsPath string log.Printf("Packing data directory...%s", setting.AppDataPath)
if setting.SessionConfig.Provider == "file" {
if len(setting.SessionConfig.ProviderConfig) == 0 {
setting.SessionConfig.ProviderConfig = "data/sessions"
}
sessionAbsPath, _ = filepath.Abs(setting.SessionConfig.ProviderConfig)
}
if err := zipAddDirectoryExclude(z, "data", setting.AppDataPath, sessionAbsPath); err != nil { var sessionAbsPath string
log.Fatalf("Fail to include data directory: %v", err) if setting.SessionConfig.Provider == "file" {
if len(setting.SessionConfig.ProviderConfig) == 0 {
setting.SessionConfig.ProviderConfig = "data/sessions"
}
sessionAbsPath, _ = filepath.Abs(setting.SessionConfig.ProviderConfig)
}
if err := zipAddDirectoryExclude(z, "data", setting.AppDataPath, sessionAbsPath); err != nil {
log.Fatalf("Failed to include data directory: %v", err)
}
} }
if err := z.AddDir("log", setting.LogRootPath); err != nil { if err := z.AddDir("log", setting.LogRootPath); err != nil {