Skip to content

Commit

Permalink
fix CI build
Browse files Browse the repository at this point in the history
  • Loading branch information
adelowo committed Sep 18, 2019
1 parent 7832a9a commit 9355bbc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
5 changes: 3 additions & 2 deletions models/migrations/v95.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/setting"

"github.com/go-xorm/xorm"
)

Expand All @@ -25,8 +26,8 @@ func deleteOrphanedAttachments(x *xorm.Engine) error {
sess := x.NewSession()
defer sess.Close()

err := sess.BufferSize(setting.IterateBufferSize).
Where("`comment_id` = 0 and (`release_id` = 0 or `release_id` not in (select `id` from `releases`))").Cols("uuid").
err := sess.BufferSize(setting.Database.IterateBufferSize).
Where("`comment_id` = 0 and (`release_id` = 0 or `release_id` not in (select `id` from `release`))").Cols("uuid").
Iterate(new(Attachment),
func(idx int, bean interface{}) error {
attachment := bean.(*Attachment)
Expand Down
25 changes: 12 additions & 13 deletions models/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,17 @@ func DeleteReleaseByID(id int64, doer *User, delTag bool) error {
return fmt.Errorf("LoadAttributes: %v", err)
}

if _, err := x.Delete(&Attachment{ReleaseID: id}); err != nil {
return err
}

for i := range rel.Attachments {
attachment := rel.Attachments[i]
if err := os.RemoveAll(attachment.LocalPath()); err != nil {
return err
}
}

mode, _ := AccessLevel(doer, rel.Repo)
if err := PrepareWebhooks(rel.Repo, HookEventRelease, &api.ReleasePayload{
Action: api.HookReleaseDeleted,
Expand All @@ -370,19 +381,7 @@ func DeleteReleaseByID(id int64, doer *User, delTag bool) error {
go HookQueue.Add(rel.Repo.ID)
}

uuids := make([]string, 0, len(rel.Attachments))

for i := range rel.Attachments {
attachment := rel.Attachments[i]
if err := os.RemoveAll(attachment.LocalPath()); err != nil {
return err
}

uuids = append(uuids, attachment.UUID)
}

_, err := x.Delete(&Attachment{ReleaseID: id})
return err
return nil
}

// SyncReleasesWithTags synchronizes release table with repository tags
Expand Down

0 comments on commit 9355bbc

Please sign in to comment.