Skip to content

Commit c1c849c

Browse files
GustedStelios Malathouras
Gusted
authored and
Stelios Malathouras
committed
Fix outType on gitea dump (go-gitea#18000)
- Force to output the dump file to use the given `--type`. - Resolves go-gitea#17959
1 parent 9fd007b commit c1c849c

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
@@ -86,7 +86,7 @@ func (o outputType) String() string {
8686
}
8787

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

@@ -152,12 +152,16 @@ func fatal(format string, args ...interface{}) {
152152
func runDump(ctx *cli.Context) error {
153153
var file *os.File
154154
fileName := ctx.String("file")
155+
outType := ctx.String("type")
155156
if fileName == "-" {
156157
file = os.Stdout
157158
err := log.DelLogger("console")
158159
if err != nil {
159160
fatal("Deleting default logger failed. Can not write to stdout: %v", err)
160161
}
162+
} else {
163+
fileName = strings.TrimSuffix(fileName, path.Ext(fileName))
164+
fileName += "." + outType
161165
}
162166
setting.LoadFromExisting()
163167

@@ -200,7 +204,6 @@ func runDump(ctx *cli.Context) error {
200204
}
201205

202206
verbose := ctx.Bool("verbose")
203-
outType := ctx.String("type")
204207
var iface interface{}
205208
if fileName == "-" {
206209
iface, err = archiver.ByExtension(fmt.Sprintf(".%s", outType))

0 commit comments

Comments
 (0)