From 53efbeadc12f5e84b72da6159aedc11f10d2ab7c Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 16 Mar 2017 09:23:12 +0800 Subject: [PATCH] bug fix for dump when data directoryis not exist (#1025) (#1100) --- cmd/dump.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/cmd/dump.go b/cmd/dump.go index c44c94fd1..b21abc289 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -17,6 +17,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/setting" "github.com/Unknwon/cae/zip" + "github.com/Unknwon/com" "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("Packing data directory...%s", setting.AppDataPath) - var sessionAbsPath string - if setting.SessionConfig.Provider == "file" { - if len(setting.SessionConfig.ProviderConfig) == 0 { - setting.SessionConfig.ProviderConfig = "data/sessions" - } - sessionAbsPath, _ = filepath.Abs(setting.SessionConfig.ProviderConfig) - } + if com.IsExist(setting.AppDataPath) { + log.Printf("Packing data directory...%s", setting.AppDataPath) - if err := zipAddDirectoryExclude(z, "data", setting.AppDataPath, sessionAbsPath); err != nil { - log.Fatalf("Fail to include data directory: %v", err) + var sessionAbsPath string + 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 {