feat: add architecture-specific removal support for arch package (#5351)

- [x] add architecture-specific removal support
- [x] Fix upload competition
- [x] Fix not checking input when downloading

docs: https://codeberg.org/forgejo/docs/pulls/874

### Release notes

- [ ] I do not want this change to show in the release notes.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5351
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Exploding Dragon <explodingfkl@gmail.com>
Co-committed-by: Exploding Dragon <explodingfkl@gmail.com>
This commit is contained in:
Exploding Dragon 2024-09-27 08:21:22 +00:00 committed by Earl Warren
parent 89d9307d56
commit 89742c4913
7 changed files with 151 additions and 100 deletions

View file

@ -175,18 +175,20 @@ func CommonRoutes() *web.Route {
arch.PushPackage(ctx)
return
} else if isDelete {
if groupLen < 2 {
if groupLen < 3 {
ctx.Status(http.StatusBadRequest)
return
}
if groupLen == 2 {
if groupLen == 3 {
ctx.SetParams("group", "")
ctx.SetParams("package", pathGroups[0])
ctx.SetParams("version", pathGroups[1])
ctx.SetParams("arch", pathGroups[2])
} else {
ctx.SetParams("group", strings.Join(pathGroups[:groupLen-2], "/"))
ctx.SetParams("package", pathGroups[groupLen-2])
ctx.SetParams("version", pathGroups[groupLen-1])
ctx.SetParams("group", strings.Join(pathGroups[:groupLen-3], "/"))
ctx.SetParams("package", pathGroups[groupLen-3])
ctx.SetParams("version", pathGroups[groupLen-2])
ctx.SetParams("arch", pathGroups[groupLen-1])
}
reqPackageAccess(perm.AccessModeWrite)(ctx)
if ctx.Written() {