Skip to content

Commit b72b3eb

Browse files
committed
apply @guillep2k suggestion for better if flow
1 parent 86c68ac commit b72b3eb

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

routers/routes/routes.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -490,12 +490,6 @@ func RegisterRoutes(m *macaron.Macaron) {
490490
return
491491
}
492492

493-
//Attachement without issue or release attached should not be returned
494-
if !attach.IsLinked() {
495-
ctx.Error(404)
496-
return
497-
}
498-
//Check issue access
499493
if attach.IssueID != 0 {
500494
iss, err := models.GetIssueByID(attach.IssueID)
501495
if err != nil {
@@ -506,10 +500,7 @@ func RegisterRoutes(m *macaron.Macaron) {
506500
ctx.Error(403)
507501
return
508502
}
509-
}
510-
511-
//Check release access
512-
if attach.ReleaseID != 0 {
503+
} else if attach.ReleaseID != 0 {
513504
rel, err := models.GetReleaseByID(attach.ReleaseID)
514505
if err != nil {
515506
ctx.ServerError("GetAttachmentByUUID.GetReleaseByID", err)
@@ -519,8 +510,10 @@ func RegisterRoutes(m *macaron.Macaron) {
519510
ctx.Error(403)
520511
return
521512
}
513+
} else {
514+
ctx.Error(404)
522515
}
523-
516+
524517
//If we have matched a access release or issue
525518
fr, err := os.Open(attach.LocalPath())
526519
if err != nil {

0 commit comments

Comments
 (0)