Skip to content

Commit 1e319ba

Browse files
zeripath6543
andauthored
When dumping trim the standard suffices instead of a random suffix (#19440)
* 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 <[email protected]> * fix enum with to have correct supported types only Co-authored-by: 6543 <[email protected]>
1 parent a7f0ce6 commit 1e319ba

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/dump.go

Lines changed: 7 additions & 2 deletions
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", "rar", "tar", "sz", "tar.gz", "tar.xz", "tar.bz2", "tar.br", "tar.lz4"},
89+
Enum: []string{"zip", "tar", "tar.sz", "tar.gz", "tar.xz", "tar.bz2", "tar.br", "tar.lz4"},
9090
Default: "zip",
9191
}
9292

@@ -160,7 +160,12 @@ func runDump(ctx *cli.Context) error {
160160
fatal("Deleting default logger failed. Can not write to stdout: %v", err)
161161
}
162162
} else {
163-
fileName = strings.TrimSuffix(fileName, path.Ext(fileName))
163+
for _, suffix := range outputTypeEnum.Enum {
164+
if strings.HasSuffix(fileName, "."+suffix) {
165+
fileName = strings.TrimSuffix(fileName, "."+suffix)
166+
break
167+
}
168+
}
164169
fileName += "." + outType
165170
}
166171
setting.LoadFromExisting()

0 commit comments

Comments
 (0)