summaryrefslogtreecommitdiffhomepage
path: root/SecretKey.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-11-06 11:50:16 -0400
committerJoey Hess <joeyh@joeyh.name>2016-11-06 11:50:16 -0400
commit2a555c479e078519b2e7d7b7258e6ba37ec3e22f (patch)
treec51663051d601cc59ea9d49ebcd5a26cdde91498 /SecretKey.hs
parent9e0ca8324a28f38acc0deefa23fb056830fecf0a (diff)
downloadkeysafe-2a555c479e078519b2e7d7b7258e6ba37ec3e22f.tar.gz
Defer requesting secret key from gpg until just before backup
So the user knows why gpg is asking for this secret key to be backed up. Before, this was done as soon as keysafe started, which didn't give the user any indication what was going on, unless they had multiple keys and so picked the key to back up from a list. This commit was sponsored by Thomas Hochstein on Patreon.
Diffstat (limited to 'SecretKey.hs')
-rw-r--r--SecretKey.hs9
1 files changed, 3 insertions, 6 deletions
diff --git a/SecretKey.hs b/SecretKey.hs
index 8dc2ada..15256d0 100644
--- a/SecretKey.hs
+++ b/SecretKey.hs
@@ -12,12 +12,9 @@ import qualified Data.ByteString as B
import System.IO
import System.Posix.IO
-getSecretKey :: SecretKeySource -> IO (SecretKeySource, SecretKey)
-getSecretKey sks = do
- sk <- case sks of
- GpgKey kid -> Gpg.getSecretKey kid
- KeyFile f -> SecretKey <$> B.readFile f
- return (sks, sk)
+getSecretKey :: SecretKeySource -> IO SecretKey
+getSecretKey (GpgKey kid) = Gpg.getSecretKey kid
+getSecretKey (KeyFile f) = SecretKey <$> B.readFile f
-- | Can throw exception if the secret key already exists.
writeSecretKey :: Distinguisher -> SecretKey -> IO ()