diff options
author | Gusted <williamzijl7@hotmail.com> | 2021-12-17 14:38:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-17 13:38:45 +0000 |
commit | 4bbbf356547557bd6b36d1d6cb73540a5febf120 (patch) | |
tree | 5391ddeace1c08d408e7247ef082047c10b379c9 /cmd/dump.go | |
parent | a6d4a8546a772ede0f59317eb51b9a90370cb67b (diff) | |
download | gitea-4bbbf356547557bd6b36d1d6cb73540a5febf120.tar.gz gitea-4bbbf356547557bd6b36d1d6cb73540a5febf120.zip |
Fix outType on gitea dump (#18000)
- Force to output the dump file to use the given `--type`.
- Resolves #17959
Diffstat (limited to 'cmd/dump.go')
-rw-r--r-- | cmd/dump.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cmd/dump.go b/cmd/dump.go index c158ee21f1..21d1ff6b77 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -86,7 +86,7 @@ func (o outputType) String() string { } var outputTypeEnum = &outputType{ - Enum: []string{"zip", "tar", "tar.gz", "tar.xz", "tar.bz2"}, + Enum: []string{"zip", "rar", "tar", "sz", "tar.gz", "tar.xz", "tar.bz2", "tar.br", "tar.lz4"}, Default: "zip", } @@ -152,12 +152,16 @@ func fatal(format string, args ...interface{}) { func runDump(ctx *cli.Context) error { var file *os.File fileName := ctx.String("file") + outType := ctx.String("type") if fileName == "-" { file = os.Stdout err := log.DelLogger("console") if err != nil { fatal("Deleting default logger failed. Can not write to stdout: %v", err) } + } else { + fileName = strings.TrimSuffix(fileName, path.Ext(fileName)) + fileName += "." + outType } setting.LoadFromExisting() @@ -200,7 +204,6 @@ func runDump(ctx *cli.Context) error { } verbose := ctx.Bool("verbose") - outType := ctx.String("type") var iface interface{} if fileName == "-" { iface, err = archiver.ByExtension(fmt.Sprintf(".%s", outType)) |