diff options
author | Unknwon <u@gogs.io> | 2018-08-16 20:17:19 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2018-08-16 20:17:19 +0800 |
commit | de10d9be08034ff285480c14b86be0c1824df16b (patch) | |
tree | bbb2c0908c8b6b51c97754d44675bbddbe1da834 | |
parent | 3c227af508b085f9113c36892ce9c52b940761f9 (diff) |
models: fix delete undesired release attachments when delete a comment (#4627)
Apparently, AfterDelete has ID=0
-rw-r--r-- | gogs.go | 2 | ||||
-rw-r--r-- | models/attachment.go | 2 | ||||
-rw-r--r-- | models/comment.go | 15 | ||||
-rw-r--r-- | templates/.VERSION | 2 |
4 files changed, 8 insertions, 13 deletions
@@ -16,7 +16,7 @@ import ( "github.com/gogs/gogs/pkg/setting" ) -const APP_VER = "0.11.60.0814" +const APP_VER = "0.11.61.0816" func init() { setting.AppVer = APP_VER diff --git a/models/attachment.go b/models/attachment.go index 31ca7f3e..e053ebff 100644 --- a/models/attachment.go +++ b/models/attachment.go @@ -165,7 +165,6 @@ func DeleteAttachments(attachments []*Attachment, remove bool) (int, error) { // DeleteAttachmentsByIssue deletes all attachments associated with the given issue. func DeleteAttachmentsByIssue(issueId int64, remove bool) (int, error) { attachments, err := GetAttachmentsByIssueID(issueId) - if err != nil { return 0, err } @@ -176,7 +175,6 @@ func DeleteAttachmentsByIssue(issueId int64, remove bool) (int, error) { // DeleteAttachmentsByComment deletes all attachments associated with the given comment. func DeleteAttachmentsByComment(commentId int64, remove bool) (int, error) { attachments, err := GetAttachmentsByCommentID(commentId) - if err != nil { return 0, err } diff --git a/models/comment.go b/models/comment.go index 447c15db..66531bbb 100644 --- a/models/comment.go +++ b/models/comment.go @@ -132,14 +132,6 @@ func (c *Comment) LoadAttributes() error { return c.loadAttributes(x) } -func (c *Comment) AfterDelete() { - _, err := DeleteAttachmentsByComment(c.ID, true) - - if err != nil { - log.Info("Could not delete files for comment %d on issue #%d: %s", c.ID, c.IssueID, err) - } -} - func (c *Comment) HTMLURL() string { return fmt.Sprintf("%s#issuecomment-%d", c.Issue.HTMLURL(), c.ID) } @@ -519,7 +511,12 @@ func DeleteCommentByID(doer *User, id int64) error { } if err = sess.Commit(); err != nil { - return fmt.Errorf("Commit: %v", err) + return fmt.Errorf("commit: %v", err) + } + + _, err = DeleteAttachmentsByComment(comment.ID, true) + if err != nil { + log.Error(2, "Failed to delete attachments by comment[%d]: %v", comment.ID, err) } if err = comment.Issue.LoadAttributes(); err != nil { diff --git a/templates/.VERSION b/templates/.VERSION index 94168071..d04c7a44 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.11.60.0814 +0.11.61.0816 |