1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-02 08:57:32 -04:00

Revert "packages: Calculate package size quota using package creator ID instead of owner ID (#28007)" (#28049)

This reverts commit #28007 60522fc96f.
This commit is contained in:
Lunny Xiao 2023-11-14 23:03:56 +08:00 committed by GitHub
parent 5ab3782f11
commit f65977df3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 13 deletions

View File

@ -230,15 +230,3 @@ func CalculateFileSize(ctx context.Context, opts *PackageFileSearchOptions) (int
Join("INNER", "package_blob", "package_blob.id = package_file.blob_id"). Join("INNER", "package_blob", "package_blob.id = package_file.blob_id").
SumInt(new(PackageBlob), "size") SumInt(new(PackageBlob), "size")
} }
// CalculateCreatorPackageQuota sums up all blob sizes related to package
// version creator id.
// It does NOT respect the deduplication of blobs.
func CalculateCreatorPackageQuota(ctx context.Context, creatorID int64) (int64, error) {
return db.GetEngine(ctx).
Table("package_version").
Where(builder.Eq{"creator_id": creatorID}).
Join("INNER", "package_file", "package_version.id = package_file.version_id").
Join("INNER", "package_blob", "package_blob.id = package_file.blob_id").
SumInt(new(PackageBlob), "size")
}

View File

@ -401,7 +401,9 @@ func CheckSizeQuotaExceeded(ctx context.Context, doer, owner *user_model.User, p
} }
if setting.Packages.LimitTotalOwnerSize > -1 { if setting.Packages.LimitTotalOwnerSize > -1 {
totalSize, err := packages_model.CalculateCreatorPackageQuota(ctx, doer.ID) totalSize, err := packages_model.CalculateFileSize(ctx, &packages_model.PackageFileSearchOptions{
OwnerID: owner.ID,
})
if err != nil { if err != nil {
log.Error("CalculateFileSize failed: %v", err) log.Error("CalculateFileSize failed: %v", err)
return err return err