mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +00:00
Display unreferenced packages total size in package admin panel (#22498)
This commit is contained in:
parent
7ddc11def7
commit
f59ce77772
6 changed files with 29 additions and 10 deletions
|
@ -85,7 +85,16 @@ func DeleteBlobByID(ctx context.Context, blobID int64) error {
|
|||
}
|
||||
|
||||
// GetTotalBlobSize returns the total blobs size in bytes
|
||||
func GetTotalBlobSize() (int64, error) {
|
||||
return db.GetEngine(db.DefaultContext).
|
||||
func GetTotalBlobSize(ctx context.Context) (int64, error) {
|
||||
return db.GetEngine(ctx).
|
||||
SumInt(&PackageBlob{}, "size")
|
||||
}
|
||||
|
||||
// GetTotalUnreferencedBlobSize returns the total size of all unreferenced blobs in bytes
|
||||
func GetTotalUnreferencedBlobSize(ctx context.Context) (int64, error) {
|
||||
return db.GetEngine(ctx).
|
||||
Table("package_blob").
|
||||
Join("LEFT", "package_file", "package_file.blob_id = package_blob.id").
|
||||
Where("package_file.id IS NULL").
|
||||
SumInt(&PackageBlob{}, "size")
|
||||
}
|
||||
|
|
|
@ -199,9 +199,9 @@ func SearchFiles(ctx context.Context, opts *PackageFileSearchOptions) ([]*Packag
|
|||
return pfs, count, err
|
||||
}
|
||||
|
||||
// CalculateBlobSize sums up all blob sizes matching the search options.
|
||||
// CalculateFileSize sums up all blob sizes matching the search options.
|
||||
// It does NOT respect the deduplication of blobs.
|
||||
func CalculateBlobSize(ctx context.Context, opts *PackageFileSearchOptions) (int64, error) {
|
||||
func CalculateFileSize(ctx context.Context, opts *PackageFileSearchOptions) (int64, error) {
|
||||
return db.GetEngine(ctx).
|
||||
Table("package_file").
|
||||
Where(opts.toConds()).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue