diff options
author | 6543 | 2022-04-21 00:26:03 +0200 |
---|---|---|
committer | GitHub | 2022-04-20 23:26:03 +0100 |
commit | c5fe0a096d0ba7b04dcc13ffb154a3fd55fca36b (patch) | |
tree | c36c1ccc1df28a47ffb0a3a2b0b936ba39ded7ef | |
parent | 0c7bf6801f240c2831f7dffdaa34a22a0344da0b (diff) |
When dumping trim the standard suffices instead of a random suffix (#19440) (#19447)
* When dumping trim the standard suffices instead of a random suffix
Instead of using the `path.Ext()` to trim the last "extension" suffix, just iterate
through the supported suffices and trim those.
Fix #19424
Signed-off-by: Andrew Thornton <art27@cantab.net>
* fix enum with to have correct supported types only
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
-rw-r--r-- | cmd/dump.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd/dump.go b/cmd/dump.go index d6a523006..604cbb686 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -86,7 +86,7 @@ func (o outputType) String() string { } var outputTypeEnum = &outputType{ - Enum: []string{"zip", "rar", "tar", "sz", "tar.gz", "tar.xz", "tar.bz2", "tar.br", "tar.lz4"}, + Enum: []string{"zip", "tar", "tar.sz", "tar.gz", "tar.xz", "tar.bz2", "tar.br", "tar.lz4"}, Default: "zip", } @@ -160,7 +160,12 @@ func runDump(ctx *cli.Context) error { fatal("Deleting default logger failed. Can not write to stdout: %v", err) } } else { - fileName = strings.TrimSuffix(fileName, path.Ext(fileName)) + for _, suffix := range outputTypeEnum.Enum { + if strings.HasSuffix(fileName, "."+suffix) { + fileName = strings.TrimSuffix(fileName, "."+suffix) + break + } + } fileName += "." + outType } setting.LoadFromExisting() |