diff options
author | Unknwon <u@gogs.io> | 2017-02-10 11:58:04 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-02-10 11:58:04 -0500 |
commit | 563fc7c6d7d685678f86ba13e565bafa96f005e0 (patch) | |
tree | d6d8ddf0f5cc54a211a7a38fe1ae813a10fac697 /cmd/dump.go | |
parent | 9b8fa69c15e4492c3e560e3ad968054717872257 (diff) |
dump: check existence before include data subdirs (#4100)
Diffstat (limited to 'cmd/dump.go')
-rw-r--r-- | cmd/dump.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/cmd/dump.go b/cmd/dump.go index 5bc3c639..2a243e41 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -14,6 +14,7 @@ import ( "io/ioutil" "github.com/Unknwon/cae/zip" + "github.com/Unknwon/com" "github.com/urfave/cli" "github.com/gogits/gogs/models" @@ -93,8 +94,13 @@ func runDump(ctx *cli.Context) error { } for _, dir := range []string{"attachments", "avatars"} { - if err := z.AddDir(path.Join("data", dir), path.Join(setting.AppDataPath, dir)); err != nil { - log.Fatalf("Fail to include data/%s: %v", dir, err) + dirPath := path.Join(setting.AppDataPath, dir) + if !com.IsDir(dirPath) { + continue + } + + if err := z.AddDir(path.Join("data", dir), dirPath); err != nil { + log.Fatalf("Fail to include '%s': %v", dirPath, err) } } |