@@ -1728,10 +1728,12 @@ func UpdateIssueContent(ctx *context.Context) {
1728
1728
return
1729
1729
}
1730
1730
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
+ }
1735
1737
}
1736
1738
1737
1739
content , err := markdown .RenderString (& markup.RenderContext {
@@ -2128,13 +2130,6 @@ func UpdateCommentContent(ctx *context.Context) {
2128
2130
return
2129
2131
}
2130
2132
2131
- if comment .Type == models .CommentTypeComment {
2132
- if err := comment .LoadAttachments (); err != nil {
2133
- ctx .ServerError ("LoadAttachments" , err )
2134
- return
2135
- }
2136
- }
2137
-
2138
2133
if ! ctx .IsSigned || (ctx .User .ID != comment .PosterID && ! ctx .Repo .CanWriteIssuesOrPulls (comment .Issue .IsPull )) {
2139
2134
ctx .Error (http .StatusForbidden )
2140
2135
return
@@ -2156,10 +2151,19 @@ func UpdateCommentContent(ctx *context.Context) {
2156
2151
return
2157
2152
}
2158
2153
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
+ }
2163
2167
}
2164
2168
2165
2169
content , err := markdown .RenderString (& markup.RenderContext {
0 commit comments