Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing migration v67 #5849

Merged
merged 6 commits into from
Jan 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions models/migrations/v67.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)

Expand All @@ -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
}
Expand All @@ -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).
Expand All @@ -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
}
Expand Down