aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGusted2021-12-18 02:55:24 +0100
committerGitHub2021-12-18 09:55:24 +0800
commit711ca52f1f374aea10ee75f9f6b1f352c840f3a7 (patch)
treefb4caa542fe76ea008f366736a8f81fe4a38cb58
parenta15f0cb010ac394cb238e95f913d47aba455f55e (diff)
backport: fix outType on gitea dump (#18016)
- Backport from #18000 Co-authored-by: techknowlogick <techknowlogick@gitea.io>
-rw-r--r--cmd/dump.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/cmd/dump.go b/cmd/dump.go
index 629993b6c..0f6087282 100644
--- a/cmd/dump.go
+++ b/cmd/dump.go
@@ -87,7 +87,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",
}
@@ -153,12 +153,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.NewContext()
// make sure we are logging to the console no matter what the configuration tells us do to
@@ -197,7 +201,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))