diff options
author | Steve Manuel <nilslice@gmail.com> | 2017-06-12 16:18:49 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-12 16:18:49 -0600 |
commit | 4fbc2b5a6846d5e057aae836dc3cc217aee290e8 (patch) | |
tree | 4687af83067eb36dbdf691eba22042b15fba2716 | |
parent | e3fb3aba33645ef1c7ba1d1556c806d7c0eb853b (diff) | |
parent | e320a323a07833e8d892fc16474c1d3fd954fb42 (diff) |
Merge pull request #160 from guycalledseven/ponzu-dev
delayed indexer init (fix for search not working when addons are enabled)
-rw-r--r-- | cmd/ponzu/main.go | 3 | ||||
-rw-r--r-- | system/db/init.go | 16 |
2 files changed, 19 insertions, 0 deletions
diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go index 25e1694..72f0abf 100644 --- a/cmd/ponzu/main.go +++ b/cmd/ponzu/main.go @@ -154,6 +154,9 @@ var serveCmd = &cobra.Command{ admin.Docs(docsport) } + // init search index + go db.InitSearchIndex() + // save the https port the system is listening on err := db.PutConfig("https_port", fmt.Sprintf("%d", httpsport)) if err != nil { diff --git a/system/db/init.go b/system/db/init.go index a401a2a..4f35bbc 100644 --- a/system/db/init.go +++ b/system/db/init.go @@ -98,6 +98,22 @@ func Init() { }() } +// InitSearchIndex initializes Search Index for search to be functional +// This was moved out of db.Init and put to main(), because addon checker was initializing db together with +// search indexing initialisation in time when there were no item.Types defined so search index was always +// empty when using addons. We still have no guarentee whatsoever that item.Types is defined +// Should be called from a goroutine after SetContent is successful (SortContent requirement) +func InitSearchIndex() { + for t := range item.Types { + err := search.MapIndex(t) + if err != nil { + log.Fatalln(err) + return + } + SortContent(t) + } +} + // SystemInitComplete checks if there is at least 1 admin user in the db which // would indicate that the system has been configured to the minimum required. func SystemInitComplete() bool { |