summaryrefslogtreecommitdiff
path: root/system/db
diff options
context:
space:
mode:
authorNeven Jacmenović <neven@nivas.hr>2017-06-09 23:03:20 +0200
committerNeven Jacmenović <neven@nivas.hr>2017-06-09 23:03:20 +0200
commit8e7e9dab59a951b6d129f48f18f4d14f12b0ec77 (patch)
tree155cb64198e205b9e2a8f52f70e41544ce53fe3c /system/db
parente005d7f96c1e6db638f6508c0a824e5b8bc9c59b (diff)
delayed search index initialization so search can work with addons
Diffstat (limited to 'system/db')
-rw-r--r--system/db/init.go39
1 files changed, 30 insertions, 9 deletions
diff --git a/system/db/init.go b/system/db/init.go
index a401a2a..65d3b74 100644
--- a/system/db/init.go
+++ b/system/db/init.go
@@ -85,17 +85,38 @@ 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 addoon 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() {
+ log.Println("init db gofunc START ..............................................................................")
+
+ // if len(item.Types) == 0 {
+ // log.Println("item.types = 0")
+ // time.Sleep(time.Second * 1)
+ // }
+
+ log.Printf("item.Types: %#v", item.Types)
+
+ for t := range item.Types {
+ err := search.MapIndex(t)
+ log.Printf("item.Types in gofunc: %#v", t)
+ log.Printf("err: %#v", err)
+ if err != nil {
+ log.Fatalln(err)
+ return
}
- }()
+
+ SortContent(t)
+
+ }
+
+ log.Println("init db gofunc END ..............................................................................")
+
}
// SystemInitComplete checks if there is at least 1 admin user in the db which