From 2a555c479e078519b2e7d7b7258e6ba37ec3e22f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 6 Nov 2016 11:50:16 -0400 Subject: 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. --- SecretKey.hs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'SecretKey.hs') 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 () -- cgit v1.2.3