Skip to content

Commit b07c47e

Browse files
wxiaoguangKN4CK3R
authored andcommitted
when the update request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates (go-gitea#16762)
1 parent b5cf99d commit b07c47e

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

routers/web/repo/issue.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,10 +1728,12 @@ func UpdateIssueContent(ctx *context.Context) {
17281728
return
17291729
}
17301730

1731-
files := ctx.QueryStrings("files[]")
1732-
if err := updateAttachments(issue, files); err != nil {
1733-
ctx.ServerError("UpdateAttachments", err)
1734-
return
1731+
// when update the request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates
1732+
if !ctx.QueryBool("ignore_attachments") {
1733+
if err := updateAttachments(issue, ctx.QueryStrings("files[]")); err != nil {
1734+
ctx.ServerError("UpdateAttachments", err)
1735+
return
1736+
}
17351737
}
17361738

17371739
content, err := markdown.RenderString(&markup.RenderContext{
@@ -2149,20 +2151,19 @@ func UpdateCommentContent(ctx *context.Context) {
21492151
return
21502152
}
21512153

2152-
if ctx.QueryBool("ignore_attachments") {
2153-
return
2154-
}
2155-
21562154
if comment.Type == models.CommentTypeComment {
21572155
if err := comment.LoadAttachments(); err != nil {
21582156
ctx.ServerError("LoadAttachments", err)
21592157
return
21602158
}
21612159
}
21622160

2163-
if err := updateAttachments(comment, ctx.QueryStrings("files[]")); err != nil {
2164-
ctx.ServerError("UpdateAttachments", err)
2165-
return
2161+
// when the update request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates
2162+
if !ctx.QueryBool("ignore_attachments") {
2163+
if err := updateAttachments(comment, ctx.QueryStrings("files[]")); err != nil {
2164+
ctx.ServerError("UpdateAttachments", err)
2165+
return
2166+
}
21662167
}
21672168

21682169
content, err := markdown.RenderString(&markup.RenderContext{

0 commit comments

Comments
 (0)