diff options
author | Sandro Santilli <strk@kbt.io> | 2017-12-31 15:45:46 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-12-31 16:45:46 +0200 |
commit | 8cd987af0c4669623ec350a50096433583e74828 (patch) | |
tree | b85b0a04803d8d15d4c42cab7e3e938733ff211f /models | |
parent | ae9cc8f972912678e59d840c38d31b2b4663b690 (diff) | |
download | gitea-8cd987af0c4669623ec350a50096433583e74828.tar.gz gitea-8cd987af0c4669623ec350a50096433583e74828.zip |
Add repo-sync-releases admin command (#3254)
* Add repo-sync-releases admin command
Will help recovering corrupted database, see #3247
* Load repos in chunks of 10, exit with error if unable to get a list, scan private repos, fix typo
* Fix debug output about num releases
* Introduce RepositoryListDefaultPageSize constant, set to 64
Use it from the new admin command
* Use RepositoryListDefaultPageSize in more places
* Document RepositoryListDefaultPageSize
Diffstat (limited to 'models')
-rw-r--r-- | models/issue_indexer.go | 2 | ||||
-rw-r--r-- | models/migrations/v39.go | 2 | ||||
-rw-r--r-- | models/repo_indexer.go | 2 | ||||
-rw-r--r-- | models/repo_list.go | 7 |
4 files changed, 10 insertions, 3 deletions
diff --git a/models/issue_indexer.go b/models/issue_indexer.go index 26d053a5d7..922b66f95e 100644 --- a/models/issue_indexer.go +++ b/models/issue_indexer.go @@ -29,7 +29,7 @@ func populateIssueIndexer() error { for page := 1; ; page++ { repos, _, err := SearchRepositoryByName(&SearchRepoOptions{ Page: page, - PageSize: 10, + PageSize: RepositoryListDefaultPageSize, OrderBy: SearchOrderByID, Private: true, Collaborate: util.OptionalBoolFalse, diff --git a/models/migrations/v39.go b/models/migrations/v39.go index 3547ef1f9e..42197e80f2 100644 --- a/models/migrations/v39.go +++ b/models/migrations/v39.go @@ -31,7 +31,7 @@ func releaseAddColumnIsTagAndSyncTags(x *xorm.Engine) error { // For the sake of SQLite3, we can't use x.Iterate here. offset := 0 - pageSize := 20 + pageSize := models.RepositoryListDefaultPageSize for { repos := make([]*models.Repository, 0, pageSize) if err := x.Table("repository").Asc("id").Limit(pageSize, offset).Find(&repos); err != nil { diff --git a/models/repo_indexer.go b/models/repo_indexer.go index 4877d339f8..8cc08904ed 100644 --- a/models/repo_indexer.go +++ b/models/repo_indexer.go @@ -81,7 +81,7 @@ func populateRepoIndexer() error { for page := 1; ; page++ { repos, _, err := SearchRepositoryByName(&SearchRepoOptions{ Page: page, - PageSize: 10, + PageSize: RepositoryListDefaultPageSize, OrderBy: SearchOrderByID, Private: true, }) diff --git a/models/repo_list.go b/models/repo_list.go index d13266f208..bc9b831d30 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -13,6 +13,13 @@ import ( "github.com/go-xorm/builder" ) +// RepositoryListDefaultPageSize is the default number of repositories +// to load in memory when running administrative tasks on all (or almost +// all) of them. +// The number should be low enough to avoid filling up all RAM with +// repository data... +const RepositoryListDefaultPageSize = 64 + // RepositoryList contains a list of repositories type RepositoryList []*Repository |