From 1b030931d6ac9dd34a9a67483adb6037c23b5ff2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 11 May 2016 16:09:39 -0400 Subject: Change git annex info remote encryption description to use wording closer to what's used in initremote. --- Remote/Helper/Encryptable.hs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'Remote') diff --git a/Remote/Helper/Encryptable.hs b/Remote/Helper/Encryptable.hs index 46ce57dc1..5ea4f1090 100644 --- a/Remote/Helper/Encryptable.hs +++ b/Remote/Helper/Encryptable.hs @@ -87,7 +87,7 @@ encryptionSetup c = do use m a = do showNote m cipher <- liftIO a - mapM_ showNote (describeCipher cipher) + showNote (describeCipher cipher) return (storeCipher cipher c', EncryptionIsSetup) highRandomQuality = (&&) (maybe True ( /= "false") $ M.lookup "highRandomQuality" c) @@ -169,24 +169,20 @@ extractCipher c = case (M.lookup "cipher" c, describeEncryption :: RemoteConfig -> String describeEncryption c = case extractCipher c of - Nothing -> "not encrypted" - Just cip -> "encrypted " ++ unwords (map paren (describeCipher cip)) - where - paren s = "(" ++ s ++ ")" + Nothing -> "none" + Just cip -> nameCipher cip ++ " (" ++ describeCipher cip ++ ")" + +nameCipher :: StorableCipher -> String +nameCipher (SharedCipher _) = "shared" +nameCipher (EncryptedCipher _ PubKey _) = "pubkey" +nameCipher (EncryptedCipher _ Hybrid _) = "hybrid" +nameCipher (SharedPubKeyCipher _ _) = "sharedpubkey" -describeCipher :: StorableCipher -> [String] +describeCipher :: StorableCipher -> String describeCipher c = case c of - (SharedCipher _) -> ["encryption key stored in git repository"] - (EncryptedCipher _ v ks) -> catMaybes - [ Just $ showkeys ks - , case v of - PubKey -> Nothing - Hybrid -> Just "hybrid mode" - ] - (SharedPubKeyCipher _ ks) -> - [ showkeys ks - , "shared cipher" - ] + (SharedCipher _) -> "encryption key stored in git repository" + (EncryptedCipher _ _ ks) -> showkeys ks + (SharedPubKeyCipher _ ks) -> showkeys ks where showkeys (KeyIds { keyIds = ks }) = "to gpg keys: " ++ unwords ks -- cgit v1.2.3