Skip to content

Commit

Permalink
Fix outType on gitea dump (go-gitea#18000)
Browse files Browse the repository at this point in the history
- Force to output the dump file to use the given `--type`.
- Resolves go-gitea#17959
  • Loading branch information
Gusted authored and Stelios Malathouras committed Mar 28, 2022
1 parent 9fd007b commit c1c849c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit c1c849c

Please sign in to comment.