summaryrefslogtreecommitdiffstats
path: root/models/issue_list.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-06-23 23:22:43 +0800
committerLauris BH <lauris@nix.lv>2019-06-23 18:22:43 +0300
commitaa7c34cf86081b71f796f6e5da60e62a3cda43ce (patch)
treec9e4b4f1490b43e942fa71b37748072d3fe441e8 /models/issue_list.go
parentbaefea311f1a66a97f9a2779ad3342f4f8167d28 (diff)
downloadgitea-aa7c34cf86081b71f796f6e5da60e62a3cda43ce.tar.gz
gitea-aa7c34cf86081b71f796f6e5da60e62a3cda43ce.zip
Fix error log when loading issues caused by a xorm bug (#7271)
* fix error log when loading issues caused by a xorm bug * upgrade packages * fix fmt * fix Consistency * fix tests
Diffstat (limited to 'models/issue_list.go')
-rw-r--r--models/issue_list.go76
1 files changed, 26 insertions, 50 deletions
diff --git a/models/issue_list.go b/models/issue_list.go
index 4ddb32da13..e3516b55b9 100644
--- a/models/issue_list.go
+++ b/models/issue_list.go
@@ -7,9 +7,7 @@ package models
import (
"fmt"
- "code.gitea.io/gitea/modules/log"
-
- "github.com/go-xorm/builder"
+ "xorm.io/builder"
)
// IssueList defines a list of issues
@@ -148,19 +146,17 @@ func (issues IssueList) loadLabels(e Engine) error {
var labelIssue LabelIssue
err = rows.Scan(&labelIssue)
if err != nil {
- // When there are no rows left and we try to close it, xorm will complain with an error.
- // Since that is not relevant for us, we can safely ignore it.
- if err := rows.Close(); err != nil {
- log.Error("IssueList.loadLabels: Close: %v", err)
+ if err1 := rows.Close(); err1 != nil {
+ return fmt.Errorf("IssueList.loadLabels: Close: %v", err1)
}
return err
}
issueLabels[labelIssue.IssueLabel.IssueID] = append(issueLabels[labelIssue.IssueLabel.IssueID], labelIssue.Label)
}
- // When there are no rows left and we try to close it, xorm will complain with an error.
+ // When there are no rows left and we try to close it.
// Since that is not relevant for us, we can safely ignore it.
- if err := rows.Close(); err != nil {
- log.Error("IssueList.loadLabels: Close: %v", err)
+ if err1 := rows.Close(); err1 != nil {
+ return fmt.Errorf("IssueList.loadLabels: Close: %v", err1)
}
left -= limit
issueIDs = issueIDs[limit:]
@@ -241,20 +237,16 @@ func (issues IssueList) loadAssignees(e Engine) error {
var assigneeIssue AssigneeIssue
err = rows.Scan(&assigneeIssue)
if err != nil {
- // When there are no rows left and we try to close it, xorm will complain with an error.
- // Since that is not relevant for us, we can safely ignore it.
- if err := rows.Close(); err != nil {
- log.Error("IssueList.loadAssignees: Close: %v", err)
+ if err1 := rows.Close(); err1 != nil {
+ return fmt.Errorf("IssueList.loadAssignees: Close: %v", err1)
}
return err
}
assignees[assigneeIssue.IssueAssignee.IssueID] = append(assignees[assigneeIssue.IssueAssignee.IssueID], assigneeIssue.Assignee)
}
- // When there are no rows left and we try to close it, xorm will complain with an error.
- // Since that is not relevant for us, we can safely ignore it.
- if err := rows.Close(); err != nil {
- log.Error("IssueList.loadAssignees: Close: %v", err)
+ if err1 := rows.Close(); err1 != nil {
+ return fmt.Errorf("IssueList.loadAssignees: Close: %v", err1)
}
left -= limit
issueIDs = issueIDs[limit:]
@@ -300,19 +292,15 @@ func (issues IssueList) loadPullRequests(e Engine) error {
var pr PullRequest
err = rows.Scan(&pr)
if err != nil {
- // When there are no rows left and we try to close it, xorm will complain with an error.
- // Since that is not relevant for us, we can safely ignore it.
- if err := rows.Close(); err != nil {
- log.Error("IssueList.loadPullRequests: Close: %v", err)
+ if err1 := rows.Close(); err1 != nil {
+ return fmt.Errorf("IssueList.loadPullRequests: Close: %v", err1)
}
return err
}
pullRequestMaps[pr.IssueID] = &pr
}
- // When there are no rows left and we try to close it, xorm will complain with an error.
- // Since that is not relevant for us, we can safely ignore it.
- if err := rows.Close(); err != nil {
- log.Error("IssueList.loadPullRequests: Close: %v", err)
+ if err1 := rows.Close(); err1 != nil {
+ return fmt.Errorf("IssueList.loadPullRequests: Close: %v", err1)
}
left -= limit
issuesIDs = issuesIDs[limit:]
@@ -349,19 +337,15 @@ func (issues IssueList) loadAttachments(e Engine) (err error) {
var attachment Attachment
err = rows.Scan(&attachment)
if err != nil {
- // When there are no rows left and we try to close it, xorm will complain with an error.
- // Since that is not relevant for us, we can safely ignore it.
- if err := rows.Close(); err != nil {
- log.Error("IssueList.loadAttachments: Close: %v", err)
+ if err1 := rows.Close(); err1 != nil {
+ return fmt.Errorf("IssueList.loadAttachments: Close: %v", err1)
}
return err
}
attachments[attachment.IssueID] = append(attachments[attachment.IssueID], &attachment)
}
- // When there are no rows left and we try to close it, xorm will complain with an error.
- // Since that is not relevant for us, we can safely ignore it.
- if err := rows.Close(); err != nil {
- log.Error("IssueList.loadAttachments: Close: %v", err)
+ if err1 := rows.Close(); err1 != nil {
+ return fmt.Errorf("IssueList.loadAttachments: Close: %v", err1)
}
left -= limit
issuesIDs = issuesIDs[limit:]
@@ -399,19 +383,15 @@ func (issues IssueList) loadComments(e Engine, cond builder.Cond) (err error) {
var comment Comment
err = rows.Scan(&comment)
if err != nil {
- // When there are no rows left and we try to close it, xorm will complain with an error.
- // Since that is not relevant for us, we can safely ignore it.
- if err := rows.Close(); err != nil {
- log.Error("IssueList.loadComments: Close: %v", err)
+ if err1 := rows.Close(); err1 != nil {
+ return fmt.Errorf("IssueList.loadComments: Close: %v", err1)
}
return err
}
comments[comment.IssueID] = append(comments[comment.IssueID], &comment)
}
- // When there are no rows left and we try to close it, xorm will complain with an error.
- // Since that is not relevant for us, we can safely ignore it.
- if err := rows.Close(); err != nil {
- log.Error("IssueList.loadComments: Close: %v", err)
+ if err1 := rows.Close(); err1 != nil {
+ return fmt.Errorf("IssueList.loadComments: Close: %v", err1)
}
left -= limit
issuesIDs = issuesIDs[limit:]
@@ -461,19 +441,15 @@ func (issues IssueList) loadTotalTrackedTimes(e Engine) (err error) {
var totalTime totalTimesByIssue
err = rows.Scan(&totalTime)
if err != nil {
- // When there are no rows left and we try to close it, xorm will complain with an error.
- // Since that is not relevant for us, we can safely ignore it.
- if err := rows.Close(); err != nil {
- log.Error("IssueList.loadTotalTrackedTimes: Close: %v", err)
+ if err1 := rows.Close(); err1 != nil {
+ return fmt.Errorf("IssueList.loadTotalTrackedTimes: Close: %v", err1)
}
return err
}
trackedTimes[totalTime.IssueID] = totalTime.Time
}
- // When there are no rows left and we try to close it, xorm will complain with an error.
- // Since that is not relevant for us, we can safely ignore it.
- if err := rows.Close(); err != nil {
- log.Error("IssueList.loadTotalTrackedTimes: Close: %v", err)
+ if err1 := rows.Close(); err1 != nil {
+ return fmt.Errorf("IssueList.loadTotalTrackedTimes: Close: %v", err1)
}
left -= limit
ids = ids[limit:]