backport: fix outType on gitea dump (#18016)
- Backport from #18000 Co-authored-by: techknowlogick <techknowlogick@gitea.io>release/v1.15
parent
a15f0cb010
commit
711ca52f1f
|
@ -87,7 +87,7 @@ func (o outputType) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var outputTypeEnum = &outputType{
|
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",
|
Default: "zip",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,12 +153,16 @@ func fatal(format string, args ...interface{}) {
|
||||||
func runDump(ctx *cli.Context) error {
|
func runDump(ctx *cli.Context) error {
|
||||||
var file *os.File
|
var file *os.File
|
||||||
fileName := ctx.String("file")
|
fileName := ctx.String("file")
|
||||||
|
outType := ctx.String("type")
|
||||||
if fileName == "-" {
|
if fileName == "-" {
|
||||||
file = os.Stdout
|
file = os.Stdout
|
||||||
err := log.DelLogger("console")
|
err := log.DelLogger("console")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal("Deleting default logger failed. Can not write to stdout: %v", err)
|
fatal("Deleting default logger failed. Can not write to stdout: %v", err)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
fileName = strings.TrimSuffix(fileName, path.Ext(fileName))
|
||||||
|
fileName += "." + outType
|
||||||
}
|
}
|
||||||
setting.NewContext()
|
setting.NewContext()
|
||||||
// make sure we are logging to the console no matter what the configuration tells us do to
|
// 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")
|
verbose := ctx.Bool("verbose")
|
||||||
outType := ctx.String("type")
|
|
||||||
var iface interface{}
|
var iface interface{}
|
||||||
if fileName == "-" {
|
if fileName == "-" {
|
||||||
iface, err = archiver.ByExtension(fmt.Sprintf(".%s", outType))
|
iface, err = archiver.ByExtension(fmt.Sprintf(".%s", outType))
|
||||||
|
|
Loading…
Reference in New Issue