aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/packages/npm
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-11-09 07:34:27 +0100
committerGitHub <noreply@github.com>2022-11-09 14:34:27 +0800
commit20674dd05da909b42cbdd07a6682fdf1d980f011 (patch)
treef51b4a6b907380d27381705e5b2e6a1187af167b /routers/api/packages/npm
parentcb83288530b1860677b07d72bc4ce8349e3c0d67 (diff)
downloadgitea-20674dd05da909b42cbdd07a6682fdf1d980f011.tar.gz
gitea-20674dd05da909b42cbdd07a6682fdf1d980f011.zip
Add package registry quota limits (#21584)
Related #20471 This PR adds global quota limits for the package registry. Settings for individual users/orgs can be added in a seperate PR using the settings table. Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'routers/api/packages/npm')
-rw-r--r--routers/api/packages/npm/npm.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/routers/api/packages/npm/npm.go b/routers/api/packages/npm/npm.go
index 82dae0cf43..6d589bde3a 100644
--- a/routers/api/packages/npm/npm.go
+++ b/routers/api/packages/npm/npm.go
@@ -180,16 +180,20 @@ func UploadPackage(ctx *context.Context) {
PackageFileInfo: packages_service.PackageFileInfo{
Filename: npmPackage.Filename,
},
- Data: buf,
- IsLead: true,
+ Creator: ctx.Doer,
+ Data: buf,
+ IsLead: true,
},
)
if err != nil {
- if err == packages_model.ErrDuplicatePackageVersion {
+ switch err {
+ case packages_model.ErrDuplicatePackageVersion:
apiError(ctx, http.StatusBadRequest, err)
- return
+ case packages_service.ErrQuotaTotalCount, packages_service.ErrQuotaTypeSize, packages_service.ErrQuotaTotalSize:
+ apiError(ctx, http.StatusForbidden, err)
+ default:
+ apiError(ctx, http.StatusInternalServerError, err)
}
- apiError(ctx, http.StatusInternalServerError, err)
return
}