Skip to content

Commit

Permalink
Fix issue boltdb#547 'Deleting bucket after inserting a nil value'
Browse files Browse the repository at this point in the history
Looks like any key with a nil value would be considered as a sub
bucket, replaced the previous 'v == nil' test by a more explicit test
on flags. In the general case it should do the same (a sub-bucket does
not have a non-nil value, does it?) but it should also handle properly
the case of nil values on real keys.
  • Loading branch information
Christian Mauduit committed Apr 13, 2016
1 parent 144418e commit 77ae42b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (b *Bucket) DeleteBucket(key []byte) error {
// Recursively delete all child buckets.
child := b.Bucket(key)
err := child.ForEach(func(k, v []byte) error {
if v == nil {
if _, _, childFlags := child.Cursor().seek(k); (childFlags & bucketLeafFlag) != 0 {
if err := child.DeleteBucket(k); err != nil {
return fmt.Errorf("delete bucket: %s", err)
}
Expand Down

0 comments on commit 77ae42b

Please sign in to comment.