From a807031a3093964387171a5bb07cc2c9181f0444 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 6 Sep 2021 22:46:20 +0800 Subject: Fix storage Iterate bug and Add storage doctor to delete garbage attachments (#16971) * Fix storage Iterate bug and Add storage doctor to delete garbage attachments * Close object when used --- models/attachment.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'models') diff --git a/models/attachment.go b/models/attachment.go index e12609f810..4e0ccba5a0 100644 --- a/models/attachment.go +++ b/models/attachment.go @@ -144,6 +144,11 @@ func GetAttachmentByUUID(uuid string) (*Attachment, error) { return getAttachmentByUUID(x, uuid) } +// ExistAttachmentsByUUID returns true if attachment is exist by given UUID +func ExistAttachmentsByUUID(uuid string) (bool, error) { + return x.Where("`uuid`=?", uuid).Exist(new(Attachment)) +} + // GetAttachmentByReleaseIDFileName returns attachment by given releaseId and fileName. func GetAttachmentByReleaseIDFileName(releaseID int64, fileName string) (*Attachment, error) { return getAttachmentByReleaseIDFileName(x, releaseID, fileName) -- cgit v1.2.3