Skip to content

Commit c5fe0a0

Browse files
6543zeripath
andauthored
When dumping trim the standard suffices instead of a random suffix (go-gitea#19440) (go-gitea#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 go-gitea#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>
1 parent 0c7bf68 commit c5fe0a0

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)