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/vagrant | |
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/vagrant')
-rw-r--r-- | routers/api/packages/vagrant/vagrant.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/routers/api/packages/vagrant/vagrant.go b/routers/api/packages/vagrant/vagrant.go index 7750e5dc4b..31ac56a532 100644 --- a/routers/api/packages/vagrant/vagrant.go +++ b/routers/api/packages/vagrant/vagrant.go @@ -193,19 +193,23 @@ func UploadPackageFile(ctx *context.Context) { PackageFileInfo: packages_service.PackageFileInfo{ Filename: strings.ToLower(boxProvider), }, - Data: buf, - IsLead: true, + Creator: ctx.Doer, + Data: buf, + IsLead: true, Properties: map[string]string{ vagrant_module.PropertyProvider: strings.TrimSuffix(boxProvider, ".box"), }, }, ) if err != nil { - if err == packages_model.ErrDuplicatePackageFile { + switch err { + case packages_model.ErrDuplicatePackageFile: apiError(ctx, http.StatusConflict, 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 } |