mirror of https://github.com/gogs/gogs.git
models: fix delete undesired release attachments when delete a comment (#4627)
Apparently, AfterDelete has ID=0pull/5388/head
parent
3c227af508
commit
de10d9be08
2
gogs.go
2
gogs.go
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.11.60.0814
|
||||
0.11.61.0816
|
||||
|
|
Loading…
Reference in New Issue