1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 10:18:38 +00:00

refactor(models/attachement): use getAttachmentsByUUIDs (#9317)

This commit is contained in:
Antoine GIRARD
2019-12-11 01:01:52 +01:00
committed by zeripath
parent 50da9f7dae
commit c3d31e5534
4 changed files with 23 additions and 20 deletions

View File

@@ -129,16 +129,9 @@ func UpdateRelease(rel *Release) error {
// AddReleaseAttachments adds a release attachments
func AddReleaseAttachments(releaseID int64, attachmentUUIDs []string) (err error) {
// Check attachments
var attachments = make([]*Attachment, 0)
for _, uuid := range attachmentUUIDs {
attach, err := getAttachmentByUUID(x, uuid)
if err != nil {
if IsErrAttachmentNotExist(err) {
continue
}
return fmt.Errorf("getAttachmentByUUID [%s]: %v", uuid, err)
}
attachments = append(attachments, attach)
attachments, err := GetAttachmentsByUUIDs(attachmentUUIDs)
if err != nil {
return fmt.Errorf("GetAttachmentsByUUIDs [uuids: %v]: %v", attachmentUUIDs, err)
}
for i := range attachments {