@@ -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 {
@@ -2128,13 +2130,6 @@ func UpdateCommentContent(ctx *context.Context) {
21282130 return
21292131 }
21302132
2131- if comment .Type == models .CommentTypeComment {
2132- if err := comment .LoadAttachments (); err != nil {
2133- ctx .ServerError ("LoadAttachments" , err )
2134- return
2135- }
2136- }
2137-
21382133 if ! ctx .IsSigned || (ctx .User .ID != comment .PosterID && ! ctx .Repo .CanWriteIssuesOrPulls (comment .Issue .IsPull )) {
21392134 ctx .Error (http .StatusForbidden )
21402135 return
@@ -2156,10 +2151,19 @@ func UpdateCommentContent(ctx *context.Context) {
21562151 return
21572152 }
21582153
2159- files := ctx .QueryStrings ("files[]" )
2160- if err := updateAttachments (comment , files ); err != nil {
2161- ctx .ServerError ("UpdateAttachments" , err )
2162- return
2154+ if comment .Type == models .CommentTypeComment {
2155+ if err := comment .LoadAttachments (); err != nil {
2156+ ctx .ServerError ("LoadAttachments" , err )
2157+ return
2158+ }
2159+ }
2160+
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+ }
21632167 }
21642168
21652169 content , err := markdown .RenderString (& markup.RenderContext {
0 commit comments