summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/repo.go8
-rw-r--r--routers/repo/issue.go8
-rw-r--r--routers/user/home.go16
3 files changed, 22 insertions, 10 deletions
diff --git a/models/repo.go b/models/repo.go
index 6e27a0cc12..295b9af35f 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -676,6 +676,14 @@ func DeleteRepository(userId, repoId int64, userName string) (err error) {
sess.Rollback()
return err
}
+ if _, err = sess.Delete(&Issue{RepoId: repoId}); err != nil {
+ sess.Rollback()
+ return err
+ }
+ if _, err = sess.Delete(&IssueUser{RepoId: repoId}); err != nil {
+ sess.Rollback()
+ return err
+ }
rawSql := "UPDATE `user` SET num_repos = num_repos - 1 WHERE id = ?"
if _, err = sess.Exec(rawSql, userId); err != nil {
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 8a894aa8c0..3e19724c38 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -337,18 +337,18 @@ func UpdateAssignee(ctx *middleware.Context) {
return
}
- idx, err := base.StrTo(ctx.Query("issue")).Int64()
+ issueId, err := base.StrTo(ctx.Query("issue")).Int64()
if err != nil {
ctx.Error(404)
return
}
- issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx)
+ issue, err := models.GetIssueById(issueId)
if err != nil {
if err == models.ErrIssueNotExist {
- ctx.Handle(404, "issue.UpdateAssignee", err)
+ ctx.Handle(404, "issue.UpdateAssignee(GetIssueById)", err)
} else {
- ctx.Handle(500, "issue.UpdateAssignee(GetIssueByIndex)", err)
+ ctx.Handle(500, "issue.UpdateAssignee(GetIssueById)", err)
}
return
}
diff --git a/routers/user/home.go b/routers/user/home.go
index a7a36b4bd7..2a2401c58f 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -221,18 +221,23 @@ func Issues(ctx *middleware.Context) {
issues[i], err = models.GetIssueById(ius[i].IssueId)
if err != nil {
if err == models.ErrIssueNotExist {
- log.Error("user.Issues(#%d): issue not exist", ius[i].IssueId)
+ log.Warn("user.Issues(GetIssueById #%d): issue not exist", ius[i].IssueId)
continue
} else {
- ctx.Handle(500, "user.Issues(GetIssue)", err)
+ ctx.Handle(500, fmt.Sprintf("user.Issues(GetIssueById #%d)", ius[i].IssueId), err)
return
}
}
issues[i].Repo, err = models.GetRepositoryById(issues[i].RepoId)
if err != nil {
- ctx.Handle(500, "user.Issues(GetRepositoryById)", err)
- return
+ if err == models.ErrRepoNotExist {
+ log.Warn("user.Issues(GetRepositoryById #%d): repository not exist", issues[i].RepoId)
+ continue
+ } else {
+ ctx.Handle(500, fmt.Sprintf("user.Issues(GetRepositoryById #%d)", issues[i].RepoId), err)
+ return
+ }
}
if err = issues[i].Repo.GetOwner(); err != nil {
@@ -240,8 +245,7 @@ func Issues(ctx *middleware.Context) {
return
}
- issues[i].Poster, err = models.GetUserById(issues[i].PosterId)
- if err != nil {
+ if err = issues[i].GetPoster(); err != nil {
ctx.Handle(500, "user.Issues(GetUserById)", err)
return
}