Skip to content

Commit aaed5c9

Browse files
committed
remove the code extract to other pull requests
1 parent e279f0e commit aaed5c9

File tree

2 files changed

+0
-28
lines changed

2 files changed

+0
-28
lines changed

models/issues/comment.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,15 +1155,6 @@ func DeleteComment(ctx context.Context, comment *Comment) error {
11551155
return err
11561156
}
11571157

1158-
// delete review if the comment is the last comment of the review
1159-
if comment.ReviewID > 0 {
1160-
if _, err := db.GetEngine(ctx).ID(comment.ReviewID).
1161-
Where("NOT EXISTS (SELECT 1 FROM comment WHERE review_id = ?)", comment.ReviewID).
1162-
Delete(new(Review)); err != nil {
1163-
return err
1164-
}
1165-
}
1166-
11671158
if err := comment.neuterCrossReferences(ctx); err != nil {
11681159
return err
11691160
}

services/issue/comments.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"code.gitea.io/gitea/modules/gitrepo"
1818
"code.gitea.io/gitea/modules/json"
1919
"code.gitea.io/gitea/modules/log"
20-
"code.gitea.io/gitea/modules/storage"
2120
"code.gitea.io/gitea/modules/timeutil"
2221
git_service "code.gitea.io/gitea/services/git"
2322
notify_service "code.gitea.io/gitea/services/notify"
@@ -136,19 +135,10 @@ func UpdateComment(ctx context.Context, c *issues_model.Comment, contentVersion
136135
// DeleteComment deletes the comment
137136
func DeleteComment(ctx context.Context, doer *user_model.User, comment *issues_model.Comment) error {
138137
err := db.WithTx(ctx, func(ctx context.Context) error {
139-
if err := comment.LoadAttachments(ctx); err != nil {
140-
return err
141-
}
142-
143138
if err := issues_model.DeleteComment(ctx, comment); err != nil {
144139
return err
145140
}
146141

147-
// delete comment attachments
148-
if _, err := repo_model.DeleteAttachments(ctx, comment.Attachments, true); err != nil {
149-
return fmt.Errorf("delete attachments: %w", err)
150-
}
151-
152142
if comment.ReviewID > 0 {
153143
if err := comment.LoadIssue(ctx); err != nil {
154144
return err
@@ -167,15 +157,6 @@ func DeleteComment(ctx context.Context, doer *user_model.User, comment *issues_m
167157
}
168158
}
169159

170-
for _, attachment := range comment.Attachments {
171-
if err := storage.Attachments.Delete(repo_model.AttachmentRelativePath(attachment.UUID)); err != nil {
172-
// Even delete files failed, but the attachments has been removed from database, so we
173-
// should not return error but only record the error on logs.
174-
// users have to delete this attachments manually or we should have a
175-
// synchronize between database attachment table and attachment storage
176-
log.Error("delete attachment[uuid: %s] failed: %v", attachment.UUID, err)
177-
}
178-
}
179160
return nil
180161
})
181162
if err != nil {

0 commit comments

Comments
 (0)