aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2018-12-19 16:37:48 +0800
committerGitHub <noreply@github.com>2018-12-19 16:37:48 +0800
commitb65e37ed722da94f62c90e456413a99e6ec9f419 (patch)
tree494aaede8060cdbf7390b20da4e0f51e97030b28 /modules
parentc64963553a827f773e969ca4d3d411c9ad70fd9b (diff)
downloadgitea-b65e37ed722da94f62c90e456413a99e6ec9f419.tar.gz
gitea-b65e37ed722da94f62c90e456413a99e6ec9f419.zip
fix indexer reindex bug when gitea restart (#5563)
* fix issue indexer bug reindex when restart gitea * also fix code indexer reindex when gitea restart
Diffstat (limited to 'modules')
-rw-r--r--modules/indexer/issue.go14
-rw-r--r--modules/indexer/repo.go13
2 files changed, 19 insertions, 8 deletions
diff --git a/modules/indexer/issue.go b/modules/indexer/issue.go
index b0d231a7cf..29c78307b6 100644
--- a/modules/indexer/issue.go
+++ b/modules/indexer/issue.go
@@ -60,7 +60,7 @@ func InitIssueIndexer(populateIndexer func() error) {
return
}
- if err = createIssueIndexer(); err != nil {
+ if err = createIssueIndexer(setting.Indexer.IssuePath, issueIndexerLatestVersion); err != nil {
log.Fatal(4, "InitIssuesIndexer: create index, %v", err)
}
if err = populateIndexer(); err != nil {
@@ -69,7 +69,7 @@ func InitIssueIndexer(populateIndexer func() error) {
}
// createIssueIndexer create an issue indexer if one does not already exist
-func createIssueIndexer() error {
+func createIssueIndexer(path string, latestVersion int) error {
mapping := bleve.NewIndexMapping()
docMapping := bleve.NewDocumentMapping()
@@ -100,8 +100,14 @@ func createIssueIndexer() error {
mapping.AddDocumentMapping("_all", bleve.NewDocumentDisabledMapping())
var err error
- issueIndexer, err = bleve.New(setting.Indexer.IssuePath, mapping)
- return err
+ issueIndexer, err = bleve.New(path, mapping)
+ if err != nil {
+ return err
+ }
+
+ return rupture.WriteIndexMetadata(path, &rupture.IndexMetadata{
+ Version: latestVersion,
+ })
}
// IssueIndexerBatch batch to add updates to
diff --git a/modules/indexer/repo.go b/modules/indexer/repo.go
index 4d1e792152..20e0fa6b18 100644
--- a/modules/indexer/repo.go
+++ b/modules/indexer/repo.go
@@ -84,7 +84,7 @@ func InitRepoIndexer(populateIndexer func() error) {
return
}
- if err = createRepoIndexer(); err != nil {
+ if err = createRepoIndexer(setting.Indexer.RepoPath, repoIndexerLatestVersion); err != nil {
log.Fatal(4, "CreateRepoIndexer: %v", err)
}
if err = populateIndexer(); err != nil {
@@ -93,7 +93,7 @@ func InitRepoIndexer(populateIndexer func() error) {
}
// createRepoIndexer create a repo indexer if one does not already exist
-func createRepoIndexer() error {
+func createRepoIndexer(path string, latestVersion int) error {
var err error
docMapping := bleve.NewDocumentMapping()
numericFieldMapping := bleve.NewNumericFieldMapping()
@@ -119,8 +119,13 @@ func createRepoIndexer() error {
mapping.AddDocumentMapping(repoIndexerDocType, docMapping)
mapping.AddDocumentMapping("_all", bleve.NewDocumentDisabledMapping())
- repoIndexer, err = bleve.New(setting.Indexer.RepoPath, mapping)
- return err
+ repoIndexer, err = bleve.New(path, mapping)
+ if err != nil {
+ return err
+ }
+ return rupture.WriteIndexMetadata(path, &rupture.IndexMetadata{
+ Version: latestVersion,
+ })
}
func filenameIndexerID(repoID int64, filename string) string {