loopdb: allow restored databases to contain nil values

pull/238/head
Joost Jager 4 years ago
parent 3e71ff0c81
commit eaf8239e49
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -2,7 +2,6 @@ package loopdb
import (
"encoding/hex"
"errors"
"fmt"
"strings"
@ -88,6 +87,15 @@ func restoreDB(bucket *bbolt.Bucket, data map[string]interface{}) error {
for k, v := range data {
key := []byte(k)
// Store nil values.
if v == nil {
err := bucket.Put(key, nil)
if err != nil {
return err
}
continue
}
switch value := v.(type) {
// Key contains value.
@ -109,7 +117,7 @@ func restoreDB(bucket *bbolt.Bucket, data map[string]interface{}) error {
}
default:
return errors.New("invalid type")
return fmt.Errorf("invalid type %T", value)
}
}

Loading…
Cancel
Save