From 2c4046d2eb2204cf8bbaf49167abdefb11034e84 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Tue, 10 Jan 2017 12:42:26 -0800 Subject: adding Init check in func called early in process --- system/db/addon.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/db/addon.go b/system/db/addon.go index b5c4929..8ad071d 100644 --- a/system/db/addon.go +++ b/system/db/addon.go @@ -15,12 +15,6 @@ var ( ErrNoAddonExists = errors.New("No addon exists.") ) -func init() { - if store == nil { - Init() - } -} - // Addon looks for an addon by its addon_reverse_dns as the key and returns // the url.Values representation of an addon func Addon(key string) (url.Values, error) { @@ -143,6 +137,11 @@ func DeleteAddon(key string) error { // value at addon_reverse_dns func AddonExists(key string) bool { var exists bool + + if store == nil { + Init() + } + err := store.Update(func(tx *bolt.Tx) error { b, err := tx.CreateBucketIfNotExists([]byte("__addons")) if err != nil { -- cgit v1.2.3