@@ -135,8 +135,8 @@ func UpdateComment(ctx context.Context, c *issues_model.Comment, contentVersion
135
135
}
136
136
137
137
// deleteComment deletes the comment
138
- func deleteComment (ctx context.Context , comment * issues_model.Comment , removeAttachments bool ) (* issues_model.Comment , func () , error ) {
139
- storageCleanup := util .NewPostTxAction ()
138
+ func deleteComment (ctx context.Context , comment * issues_model.Comment , removeAttachments bool ) (* issues_model.Comment , util. PostTxAction , error ) {
139
+ postTxActions := util .NewPostTxAction ()
140
140
deletedReviewComment , err := db .WithTx2 (ctx , func (ctx context.Context ) (* issues_model.Comment , error ) {
141
141
if removeAttachments {
142
142
// load attachments before deleting the comment
@@ -157,7 +157,7 @@ func deleteComment(ctx context.Context, comment *issues_model.Comment, removeAtt
157
157
}
158
158
159
159
// the storage cleanup function to remove attachments could be called after all transactions are committed
160
- storageCleanup = storageCleanup .Append (func () {
160
+ postTxActions = postTxActions .Append (func () {
161
161
for _ , a := range comment .Attachments {
162
162
if err := storage .Attachments .Delete (a .RelativePath ()); err != nil {
163
163
if ! errors .Is (err , os .ErrNotExist ) {
@@ -178,15 +178,15 @@ func deleteComment(ctx context.Context, comment *issues_model.Comment, removeAtt
178
178
if err != nil {
179
179
return nil , nil , err
180
180
}
181
- return deletedReviewComment , storageCleanup , nil
181
+ return deletedReviewComment , postTxActions , nil
182
182
}
183
183
184
184
func DeleteComment (ctx context.Context , doer * user_model.User , comment * issues_model.Comment ) (* issues_model.Comment , error ) {
185
- deletedReviewComment , cleanup , err := deleteComment (ctx , comment , true )
185
+ deletedReviewComment , postTxActions , err := deleteComment (ctx , comment , true )
186
186
if err != nil {
187
187
return nil , err
188
188
}
189
- cleanup ()
189
+ postTxActions ()
190
190
191
191
notify_service .DeleteComment (ctx , doer , comment )
192
192
0 commit comments