mirror of
https://github.com/go-gitea/gitea.git
synced 2025-08-04 11:49:29 +00:00
Fix bug
This commit is contained in:
parent
aaa53641ae
commit
2256fa7e9c
@ -223,7 +223,7 @@ func (issue *Issue) LoadPullRequest(ctx context.Context) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (issue *Issue) loadComments(ctx context.Context) (err error) {
|
func (issue *Issue) LoadComments(ctx context.Context) (err error) {
|
||||||
return issue.loadCommentsByType(ctx, CommentTypeUndefined)
|
return issue.loadCommentsByType(ctx, CommentTypeUndefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ func (issue *Issue) LoadAttributes(ctx context.Context) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = issue.loadComments(ctx); err != nil {
|
if err = issue.LoadComments(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,12 +301,14 @@ func deleteIssue(ctx context.Context, issue *issues_model.Issue) ([]string, erro
|
|||||||
attachmentPaths = append(attachmentPaths, issue.Attachments[i].RelativePath())
|
attachmentPaths = append(attachmentPaths, issue.Attachments[i].RelativePath())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: deference all review comments
|
// deference all review comments
|
||||||
|
if err := issue.LoadComments(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// delete all database data still assigned to this issue
|
// delete all database data still assigned to this issue
|
||||||
if err := db.DeleteBeans(ctx,
|
if err := db.DeleteBeans(ctx,
|
||||||
&issues_model.ContentHistory{IssueID: issue.ID},
|
&issues_model.ContentHistory{IssueID: issue.ID},
|
||||||
&issues_model.Comment{IssueID: issue.ID},
|
|
||||||
&issues_model.IssueLabel{IssueID: issue.ID},
|
&issues_model.IssueLabel{IssueID: issue.ID},
|
||||||
&issues_model.IssueDependency{IssueID: issue.ID},
|
&issues_model.IssueDependency{IssueID: issue.ID},
|
||||||
&issues_model.IssueAssignees{IssueID: issue.ID},
|
&issues_model.IssueAssignees{IssueID: issue.ID},
|
||||||
@ -327,6 +329,41 @@ func deleteIssue(ctx context.Context, issue *issues_model.Issue) ([]string, erro
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, comment := range issue.Comments {
|
||||||
|
if err := issues_model.DeleteComment(ctx, comment); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if comment.ReviewID > 0 {
|
||||||
|
if err := comment.LoadIssue(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := comment.Issue.LoadRepo(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := comment.Issue.LoadPullRequest(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := git.RemoveRef(ctx, comment.Issue.Repo.RepoPath(), issues_model.GetCodeCommentRef(comment.Issue.PullRequest.Index, comment.ID)); err != nil {
|
||||||
|
log.Error("Unable to remove ref in base repository for PR[%d] Error: %v", comment.Issue.PullRequest.ID, err)
|
||||||
|
// We should not return error here, because the comment has been removed from database.
|
||||||
|
// users have to delete this ref manually or we should have a synchronize between
|
||||||
|
// database comment table and git refs.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete all attachments related to this comment
|
||||||
|
for _, attachment := range comment.Attachments {
|
||||||
|
if err := storage.Attachments.Delete(repo_model.AttachmentRelativePath(attachment.UUID)); err != nil {
|
||||||
|
// Even delete files failed, but the attachments has been removed from database, so we
|
||||||
|
// should not return error but only record the error on logs.
|
||||||
|
// users have to delete this attachments manually or we should have a
|
||||||
|
// synchronize between database attachment table and attachment storage
|
||||||
|
log.Error("delete attachment[uuid: %s] failed: %v", attachment.UUID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := committer.Commit(); err != nil {
|
if err := committer.Commit(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user