aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorDanila Fominykh <d1nch8g@ion.lc>2023-11-13 20:38:50 -0300
committerGitHub <noreply@github.com>2023-11-14 00:38:50 +0100
commit60522fc96f1fa4675e95010e4b1535e0eac21910 (patch)
tree3e560642b7fe28a05dbbdccbe6a92761b8d9bfe7 /services
parentc6366089df8390bc1f017006caaf4d4c69825880 (diff)
downloadgitea-60522fc96f1fa4675e95010e4b1535e0eac21910.tar.gz
gitea-60522fc96f1fa4675e95010e4b1535e0eac21910.zip
packages: Calculate package size quota using package creator ID instead of owner ID (#28007)
Changed behavior to calculate package quota limit using package `creator ID` instead of `owner ID`. Currently, users are allowed to create an unlimited number of organizations, each of which has its own package limit quota, resulting in the ability for users to have unlimited package space in different organization scopes. This fix will calculate package quota based on `package version creator ID` instead of `package version owner ID` (which might be organization), so that users are not allowed to take more space than configured package settings. Also, there is a side case in which users can publish packages to a specific package version, initially published by different user, taking that user package size quota. Version in fix should be better because the total amount of space is limited to the quota for users sharing the same organization scope.
Diffstat (limited to 'services')
-rw-r--r--services/packages/packages.go4
1 files changed, 1 insertions, 3 deletions
diff --git a/services/packages/packages.go b/services/packages/packages.go
index 56d5cc04de..294ee6cc1a 100644
--- a/services/packages/packages.go
+++ b/services/packages/packages.go
@@ -401,9 +401,7 @@ func CheckSizeQuotaExceeded(ctx context.Context, doer, owner *user_model.User, p
}
if setting.Packages.LimitTotalOwnerSize > -1 {
- totalSize, err := packages_model.CalculateFileSize(ctx, &packages_model.PackageFileSearchOptions{
- OwnerID: owner.ID,
- })
+ totalSize, err := packages_model.CalculateCreatorPackageQuota(ctx, doer.ID)
if err != nil {
log.Error("CalculateFileSize failed: %v", err)
return err