Skip to content

Commit

Permalink
Revert "packages: Calculate package size quota using package creator …
Browse files Browse the repository at this point in the history
…ID instead of owner ID (#28007)" (#28049)

This reverts commit #28007 60522fc.
  • Loading branch information
lunny authored Nov 14, 2023
1 parent 5ab3782 commit f65977d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
12 changes: 0 additions & 12 deletions models/packages/package_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,3 @@ func CalculateFileSize(ctx context.Context, opts *PackageFileSearchOptions) (int
Join("INNER", "package_blob", "package_blob.id = package_file.blob_id").
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")
}
4 changes: 3 additions & 1 deletion services/packages/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,9 @@ func CheckSizeQuotaExceeded(ctx context.Context, doer, owner *user_model.User, p
}

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 {
log.Error("CalculateFileSize failed: %v", err)
return err
Expand Down

0 comments on commit f65977d

Please sign in to comment.