summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-06-10 16:53:21 -0600
committerGitHub <noreply@github.com>2017-06-10 16:53:21 -0600
commitccfbb7cb00113bf9b9c7e7ac5742df72cd5b96fd (patch)
tree553fcdb6ff4bb318879cf2418962b0927d5fb519
parent38aa0ebb1df97ff185d84da2d3c2f9a11888729b (diff)
parentea998eb195063617aa485ce99b0e5bd1697ecab5 (diff)
Merge pull request #157 from guycalledseven/ponzu-dev
Fix for search not working when addons are enabled
-rw-r--r--cmd/ponzu/main.go2
-rw-r--r--system/db/init.go23
2 files changed, 16 insertions, 9 deletions
diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go
index 7572dcc..c102aa4 100644
--- a/cmd/ponzu/main.go
+++ b/cmd/ponzu/main.go
@@ -137,6 +137,8 @@ var serveCmd = &cobra.Command{
}
}
+ 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..ad0011f 100644
--- a/system/db/init.go
+++ b/system/db/init.go
@@ -85,17 +85,22 @@ func Init() {
log.Fatalln("Failed to invalidate cache.", err)
}
- go func() {
- for t := range item.Types {
- err := search.MapIndex(t)
- if err != nil {
- log.Fatalln(err)
- return
- }
+}
- SortContent(t)
+// 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