diff options
Diffstat (limited to 'system')
-rw-r--r-- | system/db/init.go | 28 |
1 files changed, 23 insertions, 5 deletions
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 |