aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/dump.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-04-20 19:53:34 +0100
committerGitHub <noreply@github.com>2022-04-20 20:53:34 +0200
commit1e319ba41a3d5362d253fca540b13b2ee92124c8 (patch)
treea05ea4f88de381933295ad1611bbfe474cfd9ae3 /cmd/dump.go
parenta7f0ce620774be861f11b57d426ab59e27e4171a (diff)
downloadgitea-1e319ba41a3d5362d253fca540b13b2ee92124c8.tar.gz
gitea-1e319ba41a3d5362d253fca540b13b2ee92124c8.zip
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 <art27@cantab.net> * fix enum with to have correct supported types only Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'cmd/dump.go')
-rw-r--r--cmd/dump.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd/dump.go b/cmd/dump.go
index 4180425598..f72ef05e94 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()