Skip to content

Commit

Permalink
Merge pull request #157 from guycalledseven/ponzu-dev
Browse files Browse the repository at this point in the history
Fix for search not working when addons are enabled
  • Loading branch information
nilslice authored Jun 10, 2017
2 parents 38aa0eb + ea998eb commit ccfbb7c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions cmd/ponzu/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
23 changes: 14 additions & 9 deletions system/db/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ccfbb7c

Please sign in to comment.