Fix 'delete bucket' issue

This commit is contained in:
Brian Buller 2017-04-05 08:42:42 -05:00
parent e17c81af9d
commit ea0e080045

View File

@ -346,17 +346,16 @@ func (b *DB) DeleteBucket(path []string, key string) error {
if bkt == nil { if bkt == nil {
return fmt.Errorf("Couldn't find bucket " + path[0]) return fmt.Errorf("Couldn't find bucket " + path[0])
} }
var newBkt *bolt.Bucket
for idx := 1; idx < len(path); idx++ { for idx := 1; idx < len(path); idx++ {
newBkt = bkt.Bucket([]byte(path[idx])) bkt = bkt.Bucket([]byte(path[idx]))
if newBkt == nil { if bkt == nil {
return fmt.Errorf("Couldn't find bucket " + strings.Join(path[:idx], "/")) return fmt.Errorf("Couldn't find bucket " + strings.Join(path[:idx], "/"))
} }
} }
// newBkt should have the last bucket in the path // bkt should have the last bucket in the path
// Test to make sure that key is a bucket, if so, delete it // Test to make sure that key is a bucket, if so, delete it
if tst := newBkt.Bucket([]byte(key)); tst != nil { if tst := bkt.Bucket([]byte(key)); tst != nil {
return newBkt.Delete([]byte(key)) return bkt.DeleteBucket([]byte(key))
} }
return nil return nil
}) })