aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/packages/container/blob.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-01-29 18:34:29 +0100
committerGitHub <noreply@github.com>2023-01-29 11:34:29 -0600
commitd283a31f03eae2fc2bd8dc01b2c366308e81e50c (patch)
tree30669a1fea005fdf705ec4cd071a57a34a86477c /routers/api/packages/container/blob.go
parent2052a9e2b4e17704849e0968762ad7d51fe9d7b7 (diff)
downloadgitea-d283a31f03eae2fc2bd8dc01b2c366308e81e50c.tar.gz
gitea-d283a31f03eae2fc2bd8dc01b2c366308e81e50c.zip
Check quota limits for container uploads (#22450)
The test coverage has revealed that container packages were not checked against the quota limits.
Diffstat (limited to 'routers/api/packages/container/blob.go')
-rw-r--r--routers/api/packages/container/blob.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/routers/api/packages/container/blob.go b/routers/api/packages/container/blob.go
index 2e4309a2eb..f0457c55e1 100644
--- a/routers/api/packages/container/blob.go
+++ b/routers/api/packages/container/blob.go
@@ -26,14 +26,18 @@ var uploadVersionMutex sync.Mutex
// saveAsPackageBlob creates a package blob from an upload
// The uploaded blob gets stored in a special upload version to link them to the package/image
-func saveAsPackageBlob(hsr packages_module.HashedSizeReader, pi *packages_service.PackageInfo) (*packages_model.PackageBlob, error) {
+func saveAsPackageBlob(hsr packages_module.HashedSizeReader, pci *packages_service.PackageCreationInfo) (*packages_model.PackageBlob, error) {
+ if err := packages_service.CheckSizeQuotaExceeded(db.DefaultContext, pci.Creator, pci.Owner, packages_model.TypeContainer, hsr.Size()); err != nil {
+ return nil, err
+ }
+
pb := packages_service.NewPackageBlob(hsr)
exists := false
contentStore := packages_module.NewContentStore()
- uploadVersion, err := getOrCreateUploadVersion(pi)
+ uploadVersion, err := getOrCreateUploadVersion(&pci.PackageInfo)
if err != nil {
return nil, err
}