diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2022-11-09 07:34:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-09 14:34:27 +0800 |
commit | 20674dd05da909b42cbdd07a6682fdf1d980f011 (patch) | |
tree | f51b4a6b907380d27381705e5b2e6a1187af167b /routers/api/packages/pypi | |
parent | cb83288530b1860677b07d72bc4ce8349e3c0d67 (diff) | |
download | gitea-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/pypi')
-rw-r--r-- | routers/api/packages/pypi/pypi.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/routers/api/packages/pypi/pypi.go b/routers/api/packages/pypi/pypi.go index 4c8041c30c..4853e6658b 100644 --- a/routers/api/packages/pypi/pypi.go +++ b/routers/api/packages/pypi/pypi.go @@ -162,16 +162,20 @@ func UploadPackageFile(ctx *context.Context) { PackageFileInfo: packages_service.PackageFileInfo{ Filename: fileHeader.Filename, }, - Data: buf, - IsLead: true, + Creator: ctx.Doer, + Data: buf, + IsLead: true, }, ) if err != nil { - if err == packages_model.ErrDuplicatePackageFile { + switch err { + case packages_model.ErrDuplicatePackageFile: 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 } |