parent
							
								
									8510ac2687
								
							
						
					
					
						commit
						a757920f4e
					
				|  | @ -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 | ||||
| 				} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue