aboutsummaryrefslogtreecommitdiff
path: root/cmd/bolt/import.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/bolt/import.go')
-rw-r--r--cmd/bolt/import.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/cmd/bolt/import.go b/cmd/bolt/import.go
index 7554ae7..bcb7d2e 100644
--- a/cmd/bolt/import.go
+++ b/cmd/bolt/import.go
@@ -41,7 +41,8 @@ func Import(path string, input string) {
}
// Create the bucket if it doesn't exist.
- if err := tx.CreateBucketIfNotExists(message.Key); err != nil {
+ b, err := tx.CreateBucketIfNotExists(message.Key)
+ if err != nil {
return fmt.Errorf("create bucket: %s", err)
}
@@ -52,7 +53,6 @@ func Import(path string, input string) {
}
// Import all the values into the bucket.
- b := tx.Bucket(message.Key)
if err := importBucket(b, children); err != nil {
return fmt.Errorf("import bucket: %s", err)
}
@@ -70,7 +70,8 @@ func importBucket(b *bolt.Bucket, children []*rawMessage) error {
// Bucket messages are handled recursively.
if child.Type == "bucket" {
// Create the bucket if it doesn't exist.
- if err := b.CreateBucketIfNotExists(child.Key); err != nil {
+ subbucket, err := b.CreateBucketIfNotExists(child.Key)
+ if err != nil {
return fmt.Errorf("create bucket: %s", err)
}
@@ -81,7 +82,6 @@ func importBucket(b *bolt.Bucket, children []*rawMessage) error {
}
// Import subbucket.
- subbucket := b.Bucket(child.Key)
if err := importBucket(subbucket, subchildren); err != nil {
return fmt.Errorf("import bucket: %s", err)
}