summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2021-08-21 21:04:47 +0800
committerGitHub <noreply@github.com>2021-08-21 14:04:47 +0100
commit06f82641cb65c88d89bfaeca01f9fc3b32bb76b8 (patch)
tree13a348a6f9958941506b63c41ebb1ee3e41f23d2
parent0bd58d61e547f482dd3c38a30fccb4c58caf2a67 (diff)
downloadgitea-06f82641cb65c88d89bfaeca01f9fc3b32bb76b8.tar.gz
gitea-06f82641cb65c88d89bfaeca01f9fc3b32bb76b8.zip
when the update request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates (#16762)
-rw-r--r--routers/web/repo/issue.go22
1 files changed, 12 insertions, 10 deletions
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index 56561c6168..59ffe1edb1 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -1727,9 +1727,12 @@ func UpdateIssueContent(ctx *context.Context) {
return
}
- if err := updateAttachments(issue, ctx.FormStrings("files[]")); err != nil {
- ctx.ServerError("UpdateAttachments", err)
- return
+ // when update the request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates
+ if !ctx.FormBool("ignore_attachments") {
+ if err := updateAttachments(issue, ctx.FormStrings("files[]")); err != nil {
+ ctx.ServerError("UpdateAttachments", err)
+ return
+ }
}
content, err := markdown.RenderString(&markup.RenderContext{
@@ -2148,10 +2151,6 @@ func UpdateCommentContent(ctx *context.Context) {
return
}
- if ctx.FormBool("ignore_attachments") {
- return
- }
-
if comment.Type == models.CommentTypeComment {
if err := comment.LoadAttachments(); err != nil {
ctx.ServerError("LoadAttachments", err)
@@ -2159,9 +2158,12 @@ func UpdateCommentContent(ctx *context.Context) {
}
}
- if err := updateAttachments(comment, ctx.FormStrings("files[]")); err != nil {
- ctx.ServerError("UpdateAttachments", err)
- return
+ // when the update request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates
+ if !ctx.FormBool("ignore_attachments") {
+ if err := updateAttachments(comment, ctx.FormStrings("files[]")); err != nil {
+ ctx.ServerError("UpdateAttachments", err)
+ return
+ }
}
content, err := markdown.RenderString(&markup.RenderContext{