From b22d99bf5380c26a84977d0a874d7497e37f3826 Mon Sep 17 00:00:00 2001 From: stephen mcquay Date: Sun, 25 Feb 2018 01:52:57 -0800 Subject: [PATCH] Creates pgp dir if it doesn't exist --- keyring/keyring.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/keyring/keyring.go b/keyring/keyring.go index f330f94..24b8634 100644 --- a/keyring/keyring.go +++ b/keyring/keyring.go @@ -2,12 +2,23 @@ package keyring import ( "log" + "os" + "path/filepath" "github.com/pkg/errors" "golang.org/x/crypto/openpgp" + + "mcquay.me/fs" ) func NewKeyPair(root, name, email string) error { + pgpDir := filepath.Join(root, "var", "lib", "pm", "pgp") + if !fs.Exists(pgpDir) { + if err := os.MkdirAll(pgpDir, 0755); err != nil { + return errors.Wrap(err, "mk pgp dir") + } + } + e, err := openpgp.NewEntity(name, "pm", email, nil) if err != nil { errors.Wrap(err, "new entity")