summaryrefslogtreecommitdiff
path: root/system/db/init.go
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-06-12 16:36:30 -0600
committerGitHub <noreply@github.com>2017-06-12 16:36:30 -0600
commit81e1682818b96851a98426de89cbc31441049b24 (patch)
tree4687af83067eb36dbdf691eba22042b15fba2716 /system/db/init.go
parente3fb3aba33645ef1c7ba1d1556c806d7c0eb853b (diff)
parent4fbc2b5a6846d5e057aae836dc3cc217aee290e8 (diff)
Merge pull request #161 from ponzu-cms/ponzu-dev
[core] defer search indexing until addons/item types are registered
Diffstat (limited to 'system/db/init.go')
-rw-r--r--system/db/init.go16
1 files changed, 16 insertions, 0 deletions
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 {