diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-27 11:55:44 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-27 11:55:44 -0700 |
commit | 9abced434f459c20fd6629efa2be0b91e56de179 (patch) | |
tree | 050d00d7faca649cd0ce7ea7851e3781bd7b1d15 /rwtransaction.go | |
parent | Merge pull request #53 from benbjohnson/open-api (diff) | |
download | dedo-9abced434f459c20fd6629efa2be0b91e56de179.tar.gz dedo-9abced434f459c20fd6629efa2be0b91e56de179.tar.xz |
Add bucket reclamation.
After RWTransaction.DeleteBucket() is called, all pages related to the
bucket are moved to the freelist for that transaction.
Diffstat (limited to 'rwtransaction.go')
-rw-r--r-- | rwtransaction.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/rwtransaction.go b/rwtransaction.go index d9097f3..ddd4b96 100644 --- a/rwtransaction.go +++ b/rwtransaction.go @@ -63,14 +63,18 @@ func (t *RWTransaction) CreateBucketIfNotExists(name string) error { // DeleteBucket deletes a bucket. // Returns an error if the bucket cannot be found. func (t *RWTransaction) DeleteBucket(name string) error { - if b := t.Bucket(name); b == nil { + b := t.Bucket(name) + if b == nil { return ErrBucketNotFound } // Remove from buckets page. t.buckets.del(name) - // TODO(benbjohnson): Free all pages. + // Free all pages. + t.forEachPage(b.root, 0, func(p *page, depth int) { + t.db.freelist.free(t.id(), p) + }) return nil } |