summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-08-22 00:43:20 -0600
committerSteve Manuel <nilslice@gmail.com>2017-08-22 00:43:20 -0600
commit0745b136ee51528396d33588954e3772e17f28ac (patch)
treeeb4e087bea76a8d53f6d3cdb4a390006949262ca
parent4b1fe1e9ac1dffbbebecba4a82f1a735a63de4e7 (diff)
adding store access and buckets from other pkgs
-rw-r--r--system/db/init.go28
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