feat(restore): restores secret metadata byte

This commit is contained in:
Lewis Wynne 2025-11-06 23:57:01 +00:00
parent af61485deb
commit 9036efb25b

View file

@ -9,6 +9,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/dgraph-io/badger/v4"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -74,7 +75,14 @@ func restore(cmd *cobra.Command, args []string) error {
return fmt.Errorf("line %d: %w", lineNo, err) return fmt.Errorf("line %d: %w", lineNo, err)
} }
if err := wb.Set([]byte(entry.Key), value); err != nil { entryMeta := byte(0x0)
if entry.Secret {
entryMeta = metaSecret
}
writeEntry := badger.NewEntry([]byte(entry.Key), value).WithMeta(entryMeta)
if err := wb.SetEntry(writeEntry); err != nil {
return fmt.Errorf("line %d: %w", lineNo, err) return fmt.Errorf("line %d: %w", lineNo, err)
} }
restored++ restored++