Skip to content

Commit a757920

Browse files
KubqoAzeripath
authored andcommitted
Fix failing migration v67 (#5849)
Fixes #5848
1 parent 8510ac2 commit a757920

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

models/migrations/v67.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func removeStaleWatches(x *xorm.Engine) error {
4545
AccessModeRead // 1
4646
)
4747

48-
accessLevel := func(userID int64, repo *Repository) (int, error) {
48+
accessLevel := func(e *xorm.Session, userID int64, repo *Repository) (int, error) {
4949
mode := AccessModeNone
5050
if !repo.IsPrivate {
5151
mode = AccessModeRead
@@ -60,7 +60,7 @@ func removeStaleWatches(x *xorm.Engine) error {
6060
}
6161

6262
a := &Access{UserID: userID, RepoID: repo.ID}
63-
if has, err := x.Get(a); !has || err != nil {
63+
if has, err := e.Get(a); !has || err != nil {
6464
return mode, err
6565
}
6666
return a.Mode, nil
@@ -80,7 +80,7 @@ func removeStaleWatches(x *xorm.Engine) error {
8080
}
8181

8282
repoCache := make(map[int64]*Repository)
83-
err := x.BufferSize(setting.IterateBufferSize).Iterate(new(Watch),
83+
err := sess.BufferSize(setting.IterateBufferSize).Iterate(new(Watch),
8484
func(idx int, bean interface{}) error {
8585
watch := bean.(*Watch)
8686

@@ -89,14 +89,14 @@ func removeStaleWatches(x *xorm.Engine) error {
8989
repo = &Repository{
9090
ID: watch.RepoID,
9191
}
92-
if _, err := x.Get(repo); err != nil {
92+
if _, err := sess.Get(repo); err != nil {
9393
return err
9494
}
9595
repoCache[watch.RepoID] = repo
9696
}
9797

9898
// Remove watches from now unaccessible repositories
99-
mode, err := accessLevel(watch.UserID, repo)
99+
mode, err := accessLevel(sess, watch.UserID, repo)
100100
if err != nil {
101101
return err
102102
}
@@ -117,7 +117,7 @@ func removeStaleWatches(x *xorm.Engine) error {
117117
}
118118

119119
repoCache = make(map[int64]*Repository)
120-
err = x.BufferSize(setting.IterateBufferSize).
120+
err = sess.BufferSize(setting.IterateBufferSize).
121121
Distinct("issue_watch.user_id", "issue.repo_id").
122122
Join("INNER", "issue", "issue_watch.issue_id = issue.id").
123123
Where("issue_watch.is_watching = ?", true).
@@ -130,14 +130,14 @@ func removeStaleWatches(x *xorm.Engine) error {
130130
repo = &Repository{
131131
ID: watch.RepoID,
132132
}
133-
if _, err := x.Get(repo); err != nil {
133+
if _, err := sess.Get(repo); err != nil {
134134
return err
135135
}
136136
repoCache[watch.RepoID] = repo
137137
}
138138

139139
// Remove issue watches from now unaccssible repositories
140-
mode, err := accessLevel(watch.UserID, repo)
140+
mode, err := accessLevel(sess, watch.UserID, repo)
141141
if err != nil {
142142
return err
143143
}

0 commit comments

Comments
 (0)