aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/packages
diff options
context:
space:
mode:
authorNanguan Lin <70063547+lng2020@users.noreply.github.com>2023-10-10 21:39:58 +0800
committerGitHub <noreply@github.com>2023-10-10 15:39:58 +0200
commit5b6258a0b94737ec3db1ce418d0c933512a71f78 (patch)
treed1d1a78491e575734b1a683909d5860c0349a43f /routers/api/packages
parent2c7b6c378e73665920056b1b20ecd8fdd78f4045 (diff)
downloadgitea-5b6258a0b94737ec3db1ce418d0c933512a71f78.tar.gz
gitea-5b6258a0b94737ec3db1ce418d0c933512a71f78.zip
Fix the wrong HTTP response status code for duplicate packages (#27480)
fix #27470 (hope there is nothing missing 😢 ) --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Diffstat (limited to 'routers/api/packages')
-rw-r--r--routers/api/packages/alpine/alpine.go2
-rw-r--r--routers/api/packages/chef/chef.go2
-rw-r--r--routers/api/packages/composer/composer.go2
-rw-r--r--routers/api/packages/conan/conan.go2
-rw-r--r--routers/api/packages/debian/debian.go2
-rw-r--r--routers/api/packages/maven/maven.go2
-rw-r--r--routers/api/packages/npm/npm.go2
-rw-r--r--routers/api/packages/pub/pub.go2
-rw-r--r--routers/api/packages/pypi/pypi.go2
-rw-r--r--routers/api/packages/rubygems/rubygems.go2
10 files changed, 10 insertions, 10 deletions
diff --git a/routers/api/packages/alpine/alpine.go b/routers/api/packages/alpine/alpine.go
index c261eee2d2..bb14c5163a 100644
--- a/routers/api/packages/alpine/alpine.go
+++ b/routers/api/packages/alpine/alpine.go
@@ -164,7 +164,7 @@ func UploadPackageFile(ctx *context.Context) {
if err != nil {
switch err {
case packages_model.ErrDuplicatePackageVersion, packages_model.ErrDuplicatePackageFile:
- apiError(ctx, http.StatusBadRequest, err)
+ apiError(ctx, http.StatusConflict, err)
case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize:
apiError(ctx, http.StatusForbidden, err)
default:
diff --git a/routers/api/packages/chef/chef.go b/routers/api/packages/chef/chef.go
index a1f5f49bd8..f1e9ae12d8 100644
--- a/routers/api/packages/chef/chef.go
+++ b/routers/api/packages/chef/chef.go
@@ -310,7 +310,7 @@ func UploadPackage(ctx *context.Context) {
if err != nil {
switch err {
case packages_model.ErrDuplicatePackageVersion:
- apiError(ctx, http.StatusBadRequest, err)
+ apiError(ctx, http.StatusConflict, err)
case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize:
apiError(ctx, http.StatusForbidden, err)
default:
diff --git a/routers/api/packages/composer/composer.go b/routers/api/packages/composer/composer.go
index 313631d7d7..0551093cd1 100644
--- a/routers/api/packages/composer/composer.go
+++ b/routers/api/packages/composer/composer.go
@@ -247,7 +247,7 @@ func UploadPackage(ctx *context.Context) {
if err != nil {
switch err {
case packages_model.ErrDuplicatePackageVersion:
- apiError(ctx, http.StatusBadRequest, err)
+ apiError(ctx, http.StatusConflict, err)
case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize:
apiError(ctx, http.StatusForbidden, err)
default:
diff --git a/routers/api/packages/conan/conan.go b/routers/api/packages/conan/conan.go
index f440f83b24..4bf13222dc 100644
--- a/routers/api/packages/conan/conan.go
+++ b/routers/api/packages/conan/conan.go
@@ -415,7 +415,7 @@ func uploadFile(ctx *context.Context, fileFilter container.Set[string], fileKey
if err != nil {
switch err {
case packages_model.ErrDuplicatePackageFile:
- apiError(ctx, http.StatusBadRequest, err)
+ apiError(ctx, http.StatusConflict, err)
case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize:
apiError(ctx, http.StatusForbidden, err)
default:
diff --git a/routers/api/packages/debian/debian.go b/routers/api/packages/debian/debian.go
index dc7ebab096..379137e87e 100644
--- a/routers/api/packages/debian/debian.go
+++ b/routers/api/packages/debian/debian.go
@@ -189,7 +189,7 @@ func UploadPackageFile(ctx *context.Context) {
if err != nil {
switch err {
case packages_model.ErrDuplicatePackageVersion, packages_model.ErrDuplicatePackageFile:
- apiError(ctx, http.StatusBadRequest, err)
+ apiError(ctx, http.StatusConflict, err)
case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize:
apiError(ctx, http.StatusForbidden, err)
default:
diff --git a/routers/api/packages/maven/maven.go b/routers/api/packages/maven/maven.go
index 52e31e8033..0b93382b01 100644
--- a/routers/api/packages/maven/maven.go
+++ b/routers/api/packages/maven/maven.go
@@ -363,7 +363,7 @@ func UploadPackageFile(ctx *context.Context) {
if err != nil {
switch err {
case packages_model.ErrDuplicatePackageFile:
- apiError(ctx, http.StatusBadRequest, err)
+ apiError(ctx, http.StatusConflict, err)
case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize:
apiError(ctx, http.StatusForbidden, err)
default:
diff --git a/routers/api/packages/npm/npm.go b/routers/api/packages/npm/npm.go
index dd6b3f148b..170edfbe11 100644
--- a/routers/api/packages/npm/npm.go
+++ b/routers/api/packages/npm/npm.go
@@ -214,7 +214,7 @@ func UploadPackage(ctx *context.Context) {
if err != nil {
switch err {
case packages_model.ErrDuplicatePackageVersion:
- apiError(ctx, http.StatusBadRequest, err)
+ apiError(ctx, http.StatusConflict, err)
case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize:
apiError(ctx, http.StatusForbidden, err)
default:
diff --git a/routers/api/packages/pub/pub.go b/routers/api/packages/pub/pub.go
index 8460f861cb..1f605c6c9f 100644
--- a/routers/api/packages/pub/pub.go
+++ b/routers/api/packages/pub/pub.go
@@ -213,7 +213,7 @@ func UploadPackageFile(ctx *context.Context) {
if err != nil {
switch err {
case packages_model.ErrDuplicatePackageVersion:
- apiError(ctx, http.StatusBadRequest, err)
+ apiError(ctx, http.StatusConflict, err)
case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize:
apiError(ctx, http.StatusForbidden, err)
default:
diff --git a/routers/api/packages/pypi/pypi.go b/routers/api/packages/pypi/pypi.go
index 8c7f9bbf38..5718b1203b 100644
--- a/routers/api/packages/pypi/pypi.go
+++ b/routers/api/packages/pypi/pypi.go
@@ -177,7 +177,7 @@ func UploadPackageFile(ctx *context.Context) {
if err != nil {
switch err {
case packages_model.ErrDuplicatePackageFile:
- apiError(ctx, http.StatusBadRequest, err)
+ apiError(ctx, http.StatusConflict, err)
case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize:
apiError(ctx, http.StatusForbidden, err)
default:
diff --git a/routers/api/packages/rubygems/rubygems.go b/routers/api/packages/rubygems/rubygems.go
index 061fb0871b..01fd4dad66 100644
--- a/routers/api/packages/rubygems/rubygems.go
+++ b/routers/api/packages/rubygems/rubygems.go
@@ -258,7 +258,7 @@ func UploadPackageFile(ctx *context.Context) {
if err != nil {
switch err {
case packages_model.ErrDuplicatePackageVersion:
- apiError(ctx, http.StatusBadRequest, err)
+ apiError(ctx, http.StatusConflict, err)
case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize:
apiError(ctx, http.StatusForbidden, err)
default: