aboutsummaryrefslogtreecommitdiffstats
path: root/models/packages
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-11-15 08:08:59 +0000
committerGitHub <noreply@github.com>2022-11-15 16:08:59 +0800
commitc772934ff623b3a76efbe306f597695330a71287 (patch)
tree4639644b2bcc0e8ee3573283c8c7190a80b24a59 /models/packages
parentde6dfb714153c17a06406c866805a17a476c63bd (diff)
downloadgitea-c772934ff623b3a76efbe306f597695330a71287.tar.gz
gitea-c772934ff623b3a76efbe306f597695330a71287.zip
Adjust gitea doctor --run storages to check all storage types (#21785)
The doctor check `storages` currently only checks the attachment storage. This PR adds some basic garbage collection functionality for the other types of storage. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'models/packages')
-rw-r--r--models/packages/package_blob.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/models/packages/package_blob.go b/models/packages/package_blob.go
index 8c701d4285..fcb71a96ec 100644
--- a/models/packages/package_blob.go
+++ b/models/packages/package_blob.go
@@ -62,6 +62,13 @@ func GetBlobByID(ctx context.Context, blobID int64) (*PackageBlob, error) {
return pb, nil
}
+// ExistPackageBlobWithSHA returns if a package blob exists with the provided sha
+func ExistPackageBlobWithSHA(ctx context.Context, blobSha256 string) (bool, error) {
+ return db.GetEngine(ctx).Exist(&PackageBlob{
+ HashSHA256: blobSha256,
+ })
+}
+
// FindExpiredUnreferencedBlobs gets all blobs without associated files older than the specific duration
func FindExpiredUnreferencedBlobs(ctx context.Context, olderThan time.Duration) ([]*PackageBlob, error) {
pbs := make([]*PackageBlob, 0, 10)