From a757920f4e47117d2d5b94dc3e675fb8987b02d9 Mon Sep 17 00:00:00 2001 From: Jakub Arbet Date: Sat, 26 Jan 2019 15:50:36 +0100 Subject: [PATCH] Fix failing migration v67 (#5849) Fixes #5848 --- models/migrations/v67.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/models/migrations/v67.go b/models/migrations/v67.go index d4a7497ec9..74d3f379cd 100644 --- a/models/migrations/v67.go +++ b/models/migrations/v67.go @@ -45,7 +45,7 @@ func removeStaleWatches(x *xorm.Engine) error { AccessModeRead // 1 ) - accessLevel := func(userID int64, repo *Repository) (int, error) { + accessLevel := func(e *xorm.Session, userID int64, repo *Repository) (int, error) { mode := AccessModeNone if !repo.IsPrivate { mode = AccessModeRead @@ -60,7 +60,7 @@ func removeStaleWatches(x *xorm.Engine) error { } a := &Access{UserID: userID, RepoID: repo.ID} - if has, err := x.Get(a); !has || err != nil { + if has, err := e.Get(a); !has || err != nil { return mode, err } return a.Mode, nil @@ -80,7 +80,7 @@ func removeStaleWatches(x *xorm.Engine) error { } repoCache := make(map[int64]*Repository) - err := x.BufferSize(setting.IterateBufferSize).Iterate(new(Watch), + err := sess.BufferSize(setting.IterateBufferSize).Iterate(new(Watch), func(idx int, bean interface{}) error { watch := bean.(*Watch) @@ -89,14 +89,14 @@ func removeStaleWatches(x *xorm.Engine) error { repo = &Repository{ ID: watch.RepoID, } - if _, err := x.Get(repo); err != nil { + if _, err := sess.Get(repo); err != nil { return err } repoCache[watch.RepoID] = repo } // Remove watches from now unaccessible repositories - mode, err := accessLevel(watch.UserID, repo) + mode, err := accessLevel(sess, watch.UserID, repo) if err != nil { return err } @@ -117,7 +117,7 @@ func removeStaleWatches(x *xorm.Engine) error { } repoCache = make(map[int64]*Repository) - err = x.BufferSize(setting.IterateBufferSize). + err = sess.BufferSize(setting.IterateBufferSize). Distinct("issue_watch.user_id", "issue.repo_id"). Join("INNER", "issue", "issue_watch.issue_id = issue.id"). Where("issue_watch.is_watching = ?", true). @@ -130,14 +130,14 @@ func removeStaleWatches(x *xorm.Engine) error { repo = &Repository{ ID: watch.RepoID, } - if _, err := x.Get(repo); err != nil { + if _, err := sess.Get(repo); err != nil { return err } repoCache[watch.RepoID] = repo } // Remove issue watches from now unaccssible repositories - mode, err := accessLevel(watch.UserID, repo) + mode, err := accessLevel(sess, watch.UserID, repo) if err != nil { return err }