MCPcopy Create free account
hub / github.com/gogs/gogs / DeleteAttachments

Function DeleteAttachments

internal/database/attachment.go:166–180  ·  view source on GitHub ↗

DeleteAttachments deletes the given attachments and optionally the associated files.

(attachments []*Attachment, remove bool)

Source from the content-addressed store, hash-verified

164
165// DeleteAttachments deletes the given attachments and optionally the associated files.
166func DeleteAttachments(attachments []*Attachment, remove bool) (int, error) {
167 for i, a := range attachments {
168 if remove {
169 if err := os.Remove(a.LocalPath()); err != nil {
170 return i, err
171 }
172 }
173
174 if _, err := x.Delete(a); err != nil {
175 return i, err
176 }
177 }
178
179 return len(attachments), nil
180}
181
182// DeleteAttachmentsByIssue deletes all attachments associated with the given issue.
183func DeleteAttachmentsByIssue(issueID int64, remove bool) (int, error) {

Callers 3

DeleteAttachmentFunction · 0.85
DeleteAttachmentsByIssueFunction · 0.85

Calls 3

RemoveMethod · 0.80
DeleteMethod · 0.80
LocalPathMethod · 0.45

Tested by

no test coverage detected