Skip to content

Commit 30ce685

Browse files
author
Gusted
committed
backport: fix outType on gitea dump
- Backport from go-gitea#18000
1 parent 3ae4c48 commit 30ce685

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cmd/dump.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (o outputType) String() string {
8787
}
8888

8989
var outputTypeEnum = &outputType{
90-
Enum: []string{"zip", "tar", "tar.gz", "tar.xz", "tar.bz2"},
90+
Enum: []string{"zip", "rar", "tar", "sz", "tar.gz", "tar.xz", "tar.bz2", "tar.br", "tar.lz4"},
9191
Default: "zip",
9292
}
9393

@@ -153,12 +153,16 @@ func fatal(format string, args ...interface{}) {
153153
func runDump(ctx *cli.Context) error {
154154
var file *os.File
155155
fileName := ctx.String("file")
156+
outType := ctx.String("type")
156157
if fileName == "-" {
157158
file = os.Stdout
158159
err := log.DelLogger("console")
159160
if err != nil {
160161
fatal("Deleting default logger failed. Can not write to stdout: %v", err)
161162
}
163+
} else {
164+
fileName = strings.TrimSuffix(fileName, path.Ext(fileName))
165+
fileName += "." + outType
162166
}
163167
setting.NewContext()
164168
// 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 {
197201
}
198202

199203
verbose := ctx.Bool("verbose")
200-
outType := ctx.String("type")
201204
var iface interface{}
202205
if fileName == "-" {
203206
iface, err = archiver.ByExtension(fmt.Sprintf(".%s", outType))

0 commit comments

Comments
 (0)