Skip to content

Commit 86c68ac

Browse files
committed
refactor to IsLinked
1 parent f769015 commit 86c68ac

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

models/attachment.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ func (a *Attachment) IncreaseDownloadCount() error {
4242
return nil
4343
}
4444

45-
// IsNotAttached define is the attachement is linked to an issue or release
46-
func (a *Attachment) IsNotAttached() bool {
47-
return a.ReleaseID == 0 && a.IssueID == 0
45+
// IsLinked define is the attachement is linked to an issue or release
46+
func (a *Attachment) IsLinked() bool {
47+
return a.ReleaseID != 0 || a.IssueID != 0
4848
}
4949

5050
// APIFormat converts models.Attachment to api.Attachment

models/issue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) {
11711171
}
11721172

11731173
for i := 0; i < len(attachments); i++ {
1174-
if !attachments[i].IsNotAttached() {
1174+
if attachments[i].IsLinked() {
11751175
log.Error("newIssue [%s]: skipping already linked attachement", attachments[i].UUID)
11761176
continue
11771177
}

models/issue_comment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ func sendCreateCommentAction(e *xorm.Session, opts *CreateCommentOptions, commen
612612
}
613613

614614
for i := range attachments {
615-
if !attachments[i].IsNotAttached() {
615+
if attachments[i].IsLinked() {
616616
log.Error("sendCreateCommentAction [%s]: skipping already linked attachement", attachments[i].UUID)
617617
continue
618618
}

models/release.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func linkReleaseAttachments(releaseID int64, attachmentUUIDs []string) (err erro
156156
}
157157

158158
for i := range attachments {
159-
if !attachments[i].IsNotAttached() {
159+
if attachments[i].IsLinked() {
160160
log.Error("linkReleaseAttachments [%s]: skipping already linked attachement", attachments[i].UUID)
161161
continue
162162
}

routers/routes/routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ func RegisterRoutes(m *macaron.Macaron) {
491491
}
492492

493493
//Attachement without issue or release attached should not be returned
494-
if attach.IsNotAttached() {
494+
if !attach.IsLinked() {
495495
ctx.Error(404)
496496
return
497497
}

0 commit comments

Comments
 (0)