Skip to content

Commit

Permalink
Merge pull request #127 from mrjana/boltdb
Browse files Browse the repository at this point in the history
Do not return boltdb bucket not found error
  • Loading branch information
Santhosh Manohar committed Apr 15, 2016
2 parents 2a3d365 + 507066c commit 7283ef2
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions store/boltdb/boltdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ var (
// ErrMultipleEndpointsUnsupported is thrown when multiple endpoints specified for
// BoltDB. Endpoint has to be a local file path
ErrMultipleEndpointsUnsupported = errors.New("boltdb supports one endpoint and should be a file path")
// ErrBoltBucketNotFound is thrown when specified BoltBD bucket doesn't exist in the DB
ErrBoltBucketNotFound = errors.New("boltdb bucket doesn't exist")
// ErrBoltBucketOptionMissing is thrown when boltBcuket config option is missing
ErrBoltBucketOptionMissing = errors.New("boltBucket config option missing")
)
Expand Down Expand Up @@ -141,7 +139,7 @@ func (b *BoltDB) Get(key string) (*store.KVPair, error) {
err = db.View(func(tx *bolt.Tx) error {
bucket := tx.Bucket(b.boltBucket)
if bucket == nil {
return ErrBoltBucketNotFound
return store.ErrKeyNotFound
}

v := bucket.Get([]byte(key))
Expand Down Expand Up @@ -217,7 +215,7 @@ func (b *BoltDB) Delete(key string) error {
err = db.Update(func(tx *bolt.Tx) error {
bucket := tx.Bucket(b.boltBucket)
if bucket == nil {
return ErrBoltBucketNotFound
return store.ErrKeyNotFound
}
err := bucket.Delete([]byte(key))
return err
Expand All @@ -243,7 +241,7 @@ func (b *BoltDB) Exists(key string) (bool, error) {
err = db.View(func(tx *bolt.Tx) error {
bucket := tx.Bucket(b.boltBucket)
if bucket == nil {
return ErrBoltBucketNotFound
return store.ErrKeyNotFound
}

val = bucket.Get([]byte(key))
Expand Down Expand Up @@ -276,7 +274,7 @@ func (b *BoltDB) List(keyPrefix string) ([]*store.KVPair, error) {
err = db.View(func(tx *bolt.Tx) error {
bucket := tx.Bucket(b.boltBucket)
if bucket == nil {
return ErrBoltBucketNotFound
return store.ErrKeyNotFound
}

cursor := bucket.Cursor()
Expand Down Expand Up @@ -326,7 +324,7 @@ func (b *BoltDB) AtomicDelete(key string, previous *store.KVPair) (bool, error)
err = db.Update(func(tx *bolt.Tx) error {
bucket := tx.Bucket(b.boltBucket)
if bucket == nil {
return ErrBoltBucketNotFound
return store.ErrKeyNotFound
}

val = bucket.Get([]byte(key))
Expand Down Expand Up @@ -370,7 +368,7 @@ func (b *BoltDB) AtomicPut(key string, value []byte, previous *store.KVPair, opt
bucket := tx.Bucket(b.boltBucket)
if bucket == nil {
if previous != nil {
return ErrBoltBucketNotFound
return store.ErrKeyNotFound
}
bucket, err = tx.CreateBucket(b.boltBucket)
if err != nil {
Expand Down Expand Up @@ -440,7 +438,7 @@ func (b *BoltDB) DeleteTree(keyPrefix string) error {
err = db.Update(func(tx *bolt.Tx) error {
bucket := tx.Bucket(b.boltBucket)
if bucket == nil {
return ErrBoltBucketNotFound
return store.ErrKeyNotFound
}

cursor := bucket.Cursor()
Expand Down

0 comments on commit 7283ef2

Please sign in to comment.