summaryrefslogtreecommitdiff
path: root/Remote/Encryptable.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-05-15 02:49:43 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-05-15 03:38:08 -0400
commitcad0e1c8b7eb21f8dceca8dd9fa3bc1d1aa7eabd (patch)
treeb6be12dc1cc83a35ca7d89a862d85e6d71c38572 /Remote/Encryptable.hs
parentefa7f544050c0d5be6bc1b0fc0125278e475c213 (diff)
simplified a bunch of Maybe handling
Diffstat (limited to 'Remote/Encryptable.hs')
-rw-r--r--Remote/Encryptable.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/Remote/Encryptable.hs b/Remote/Encryptable.hs
index 31ef1f37a..f9b388c8a 100644
--- a/Remote/Encryptable.hs
+++ b/Remote/Encryptable.hs
@@ -73,11 +73,10 @@ encryptableRemote c storeKeyEncrypted retrieveKeyFileEncrypted r =
{- Gets encryption Cipher. The decrypted Cipher is cached in the Annex
- state. -}
remoteCipher :: RemoteConfig -> Annex (Maybe Cipher)
-remoteCipher c = do
- cache <- Annex.getState Annex.cipher
- case cache of
- Just cipher -> return $ Just cipher
- Nothing -> case extractCipher c of
+remoteCipher c = maybe expensive cached =<< Annex.getState Annex.cipher
+ where
+ cached cipher = return $ Just cipher
+ expensive = case extractCipher c of
Nothing -> return Nothing
Just encipher -> do
showNote "gpg"