diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-09-06 22:46:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-06 16:46:20 +0200 |
commit | a807031a3093964387171a5bb07cc2c9181f0444 (patch) | |
tree | 01143ab519c89cb857c71f458be376558f9758c7 /models | |
parent | 82da380af73cba733f15f12f12807a12f8efcc56 (diff) | |
download | gitea-a807031a3093964387171a5bb07cc2c9181f0444.tar.gz gitea-a807031a3093964387171a5bb07cc2c9181f0444.zip |
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
Diffstat (limited to 'models')
-rw-r--r-- | models/attachment.go | 5 |
1 files changed, 5 insertions, 0 deletions
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) |