diff options
author | Steve <nilslice@gmail.com> | 2016-10-31 00:59:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-31 00:59:57 -0700 |
commit | 645cfa39a92a9f732629f1e3206ca468ff329138 (patch) | |
tree | 89fc417b79394fb4fc58de997194b9730acfefc1 /system/db/init.go | |
parent | 96ebcb095797fe4947d647ad1aa7572d84609fc0 (diff) | |
parent | 682cc2b6d9e3524209fbe3d2773fa31e8de9b88d (diff) |
Merge pull request #11 from bosssauce/ponzu-dev
[core] Enable content to be submitted from external clients
Diffstat (limited to 'system/db/init.go')
-rw-r--r-- | system/db/init.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/system/db/init.go b/system/db/init.go index 1a5ed25..63804e1 100644 --- a/system/db/init.go +++ b/system/db/init.go @@ -13,12 +13,21 @@ import ( var store *bolt.DB +// Close exports the abillity to close our db file. Should be called with defer +// after call to Init() from the same place. +func Close() { + err := store.Close() + if err != nil { + log.Println(err) + } +} + // Init creates a db connection, initializes db with required info, sets secrets func Init() { var err error - store, err = bolt.Open("store.db", 0666, nil) + store, err = bolt.Open("system.db", 0666, nil) if err != nil { - log.Fatal(err) + log.Fatalln(err) } err = store.Update(func(tx *bolt.Tx) error { @@ -67,10 +76,9 @@ func Init() { return nil }) if err != nil { - log.Fatal("Coudn't initialize db with buckets.", err) + log.Fatalln("Coudn't initialize db with buckets.", err) } - // sort all content into type_sorted buckets go func() { for t := range content.Types { SortContent(t) @@ -99,7 +107,7 @@ func SystemInitComplete() bool { }) if err != nil { complete = false - log.Fatal(err) + log.Fatalln(err) } return complete |