diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-10-28 12:58:25 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-10-28 12:58:25 -0700 |
commit | c178f2e403b0b711d8aa3c0155d1368827f88afd (patch) | |
tree | 3550104fd9ed23859947ecce1cff8c41480d6288 /system/db/init.go | |
parent | 5c187f700fd1e868078d831b53fbfc0e256142b5 (diff) |
adding some clean up code and UI toggle for future external vs. internal posted content
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..e5a588a 100644 --- a/system/db/init.go +++ b/system/db/init.go @@ -13,12 +13,20 @@ 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,7 +75,7 @@ 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 @@ -99,7 +107,7 @@ func SystemInitComplete() bool { }) if err != nil { complete = false - log.Fatal(err) + log.Fatalln(err) } return complete |