diff options
Diffstat (limited to 'system/db')
-rw-r--r-- | system/db/content.go | 2 | ||||
-rw-r--r-- | system/db/init.go | 18 |
2 files changed, 13 insertions, 7 deletions
diff --git a/system/db/content.go b/system/db/content.go index 39ab5c2..6e70c1b 100644 --- a/system/db/content.go +++ b/system/db/content.go @@ -24,8 +24,6 @@ func SetContent(target string, data url.Values) (int, error) { t := strings.Split(target, ":") ns, id := t[0], t[1] - log.Println(ns, id, data) - // check if content id == -1 (indicating new post). // if so, run an insert which will assign the next auto incremented int. // this is done because boltdb begins its bucket auto increment value at 0, 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 |