From ea0e0800457bf127b9b05487805a8137aee087a7 Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Wed, 5 Apr 2017 08:42:42 -0500 Subject: [PATCH] Fix 'delete bucket' issue --- boltease.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/boltease.go b/boltease.go index 2831064..925bc88 100644 --- a/boltease.go +++ b/boltease.go @@ -346,17 +346,16 @@ func (b *DB) DeleteBucket(path []string, key string) error { if bkt == nil { return fmt.Errorf("Couldn't find bucket " + path[0]) } - var newBkt *bolt.Bucket for idx := 1; idx < len(path); idx++ { - newBkt = bkt.Bucket([]byte(path[idx])) - if newBkt == nil { + bkt = bkt.Bucket([]byte(path[idx])) + if bkt == nil { 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 - if tst := newBkt.Bucket([]byte(key)); tst != nil { - return newBkt.Delete([]byte(key)) + if tst := bkt.Bucket([]byte(key)); tst != nil { + return bkt.DeleteBucket([]byte(key)) } return nil })