Fixed bug that occurred with sub-buckets around level 4

This commit is contained in:
Brian Buller 2017-05-18 08:17:58 -05:00
parent 9946fceba7
commit ca8240e06d
2 changed files with 22 additions and 11 deletions

View File

@ -224,6 +224,13 @@ func (bd *BoltDB) getBucket(k string) (*BoltBucket, error) {
return nil, errors.New("Bucket Not Found")
}
func (bd *BoltDB) openAllBuckets() {
for i := range bd.buckets {
bd.buckets[i].openAllBuckets()
bd.buckets[i].expanded = true
}
}
func (bd *BoltDB) syncOpenBuckets(shadow *BoltDB) {
// First test this bucket
for i := range bd.buckets {
@ -270,23 +277,19 @@ The passed prefix is the path leading to the current bucket
func (b *BoltBucket) buildVisiblePathSlice(prefix []string) ([][]string, error) {
var retSlice [][]string
var retErr error
// Add this bucket to the prefix slice
prefix = append(prefix, b.name)
retSlice = append(retSlice, prefix)
retSlice = append(retSlice, append(prefix, b.name))
if b.expanded {
// Add subbuckets
for i := range b.buckets {
bktS, bktErr := b.buckets[i].buildVisiblePathSlice(prefix)
if bktErr == nil {
retSlice = append(retSlice, bktS...)
} else {
// Something went wrong, set the error flag
b.buckets[i].errorFlag = true
bktS, bktErr := b.buckets[i].buildVisiblePathSlice(append(prefix, b.name))
if bktErr != nil {
return retSlice, bktErr
}
retSlice = append(retSlice, bktS...)
}
// Add Pairs
// Add pairs
for i := range b.pairs {
retSlice = append(retSlice, append(prefix, b.pairs[i].key))
retSlice = append(retSlice, append(append(prefix, b.name), b.pairs[i].key))
}
}
return retSlice, retErr
@ -304,6 +307,13 @@ func (b *BoltBucket) syncOpenBuckets(shadow *BoltBucket) {
}
}
func (b *BoltBucket) openAllBuckets() {
for i := range b.buckets {
b.buckets[i].openAllBuckets()
b.buckets[i].expanded = true
}
}
func (b *BoltBucket) getBucket(k string) (*BoltBucket, error) {
for i := range b.buckets {
if b.buckets[i].name == k {

View File

@ -52,6 +52,7 @@ func main() {
// First things first, load the database into memory
memBolt.refreshDatabase()
// Kick off the UI loop
mainLoop(memBolt, style)
defer db.Close()
}