diff options
-rw-r--r-- | system/api/create.go | 2 | ||||
-rw-r--r-- | system/db/init.go | 28 |
2 files changed, 24 insertions, 6 deletions
diff --git a/system/api/create.go b/system/api/create.go index 8af415b..9012fc3 100644 --- a/system/api/create.go +++ b/system/api/create.go @@ -147,7 +147,7 @@ func createContentHandler(res http.ResponseWriter, req *http.Request) { err = hook.BeforeAPICreate(res, req) if err != nil { - log.Println("[Create] error calling BeforeAccept:", err) + log.Println("[Create] error calling BeforeCreate:", err) return } diff --git a/system/db/init.go b/system/db/init.go index 48ae641..31e9f3f 100644 --- a/system/db/init.go +++ b/system/db/init.go @@ -13,7 +13,22 @@ import ( "github.com/nilslice/jwt" ) -var store *bolt.DB +var ( + store *bolt.DB + + buckets = []string{ + "__config", "__users", + "__addons", "__uploads", + "__contentIndex", + } + + bucketsToAdd []string +) + +// Store provides access to the underlying *bolt.DB store +func Store() *bolt.DB { + return store +} // Close exports the abillity to close our db file. Should be called with defer // after call to Init() from the same place. @@ -51,10 +66,8 @@ func Init() { } // init db with other buckets as needed - buckets := []string{ - "__config", "__users", "__contentIndex", - "__addons", "__uploads", - } + buckets = append(buckets, bucketsToAdd...) + for _, name := range buckets { _, err := tx.CreateBucketIfNotExists([]byte(name)) if err != nil { @@ -86,6 +99,11 @@ func Init() { } } +// AddBucket adds a bucket to be created if it doesn't already exist +func AddBucket(name string) { + bucketsToAdd = append(bucketsToAdd, name) +} + // 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 |