aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo_indexer.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-09-23 16:45:36 +0100
committerGitHub <noreply@github.com>2021-09-23 23:45:36 +0800
commit9302eba971611601c3ebf6024e22a11c63f4e151 (patch)
treea3e5583986161ef62e7affc694098279ecf2217d /models/repo_indexer.go
parentb22be7f594401d7bd81196750456ce52185bd391 (diff)
downloadgitea-9302eba971611601c3ebf6024e22a11c63f4e151.tar.gz
gitea-9302eba971611601c3ebf6024e22a11c63f4e151.zip
DBContext is just a Context (#17100)
* DBContext is just a Context This PR removes some of the specialness from the DBContext and makes it context This allows us to simplify the GetEngine code to wrap around any context in future and means that we can change our loadRepo(e Engine) functions to simply take contexts. Signed-off-by: Andrew Thornton <art27@cantab.net> * fix unit tests Signed-off-by: Andrew Thornton <art27@cantab.net> * another place that needs to set the initial context Signed-off-by: Andrew Thornton <art27@cantab.net> * avoid race Signed-off-by: Andrew Thornton <art27@cantab.net> * change attachment error Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'models/repo_indexer.go')
-rw-r--r--models/repo_indexer.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/models/repo_indexer.go b/models/repo_indexer.go
index 4d3d18cac3..7029b0922b 100644
--- a/models/repo_indexer.go
+++ b/models/repo_indexer.go
@@ -42,7 +42,7 @@ func GetUnindexedRepos(indexerType RepoIndexerType, maxRepoID int64, page, pageS
}).And(builder.Eq{
"repository.is_empty": false,
})
- sess := db.DefaultContext().Engine().Table("repository").Join("LEFT OUTER", "repo_indexer_status", "repository.id = repo_indexer_status.repo_id AND repo_indexer_status.indexer_type = ?", indexerType)
+ sess := db.GetEngine(db.DefaultContext).Table("repository").Join("LEFT OUTER", "repo_indexer_status", "repository.id = repo_indexer_status.repo_id AND repo_indexer_status.indexer_type = ?", indexerType)
if maxRepoID > 0 {
cond = builder.And(cond, builder.Lte{
"repository.id": maxRepoID,
@@ -91,7 +91,7 @@ func (repo *Repository) getIndexerStatus(e db.Engine, indexerType RepoIndexerTyp
// GetIndexerStatus loads repo codes indxer status
func (repo *Repository) GetIndexerStatus(indexerType RepoIndexerType) (*RepoIndexerStatus, error) {
- return repo.getIndexerStatus(db.DefaultContext().Engine(), indexerType)
+ return repo.getIndexerStatus(db.GetEngine(db.DefaultContext), indexerType)
}
// updateIndexerStatus updates indexer status
@@ -120,5 +120,5 @@ func (repo *Repository) updateIndexerStatus(e db.Engine, indexerType RepoIndexer
// UpdateIndexerStatus updates indexer status
func (repo *Repository) UpdateIndexerStatus(indexerType RepoIndexerType, sha string) error {
- return repo.updateIndexerStatus(db.DefaultContext().Engine(), indexerType, sha)
+ return repo.updateIndexerStatus(db.GetEngine(db.DefaultContext), indexerType, sha)
}