diff options
Diffstat (limited to 'src/hub/src/spreadspace.org/sfive/s5store.go')
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5store.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5store.go b/src/hub/src/spreadspace.org/sfive/s5store.go index eb5793c..dda9247 100644 --- a/src/hub/src/spreadspace.org/sfive/s5store.go +++ b/src/hub/src/spreadspace.org/sfive/s5store.go @@ -51,6 +51,7 @@ const ( var ( storeBuckets = []string{latestUpdatesBn, hubUUIDsFwdBn, hubUUIDsRevBn, updatesBn, sourcesFwdBn, sourcesRevBn, clientsFwdBn, clientsRevBn, clientDataBn, userAgentsFwdBn, userAgentsRevBn} + storeIndexBuckets = []string{timestampsIdxBn} ) type Store struct { @@ -104,6 +105,11 @@ func openDB(dbPath string, readOnly bool) (db *bolt.DB, version int64, hubUUID s return errors.New("store: failed to open, bucket '" + bn + "' does not exist.") } } + for _, bn := range storeIndexBuckets { + if b := tx.Bucket([]byte(bn)); b == nil { + return errors.New("store: failed to open, index bucket '" + bn + "' does not exist - please re-index the store.") + } + } return nil }) if err != nil { @@ -124,6 +130,11 @@ func createDB(dbPath string) (db *bolt.DB, version int64, hubUUID string, err er return err } } + for _, bn := range storeIndexBuckets { + if _, err := tx.CreateBucket([]byte(bn)); err != nil { + return err + } + } b, err := tx.CreateBucket([]byte(hubInfoBn)) if err != nil { |