summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-03-02 17:41:33 +0800
committerGitHub <noreply@github.com>2017-03-02 17:41:33 +0800
commit341b3a034974ea24535eef12ec2832a6d89cb282 (patch)
treef6390e78fdc906cee1373602eebf064b7df177ad /cmd
parent2f7dc28b22f039b04aa200ee0909bf889d86e66e (diff)
downloadgitea-341b3a034974ea24535eef12ec2832a6d89cb282.tar.gz
gitea-341b3a034974ea24535eef12ec2832a6d89cb282.zip
bug fix for dump when data directoryis not exist (#1025)
Diffstat (limited to 'cmd')
-rw-r--r--cmd/dump.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/cmd/dump.go b/cmd/dump.go
index 81cd772f5d..ad095ed3b4 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"
)
@@ -114,17 +115,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("Failed 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 {