a few more field functions

This commit is contained in:
Joey Hess 2020-01-15 11:30:45 -04:00
parent 2edf0506a5
commit 6a982e38eb
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 15 additions and 10 deletions

View file

@ -21,6 +21,8 @@ module Remote.Helper.Encryptable (
extractCipher,
isEncrypted,
describeEncryption,
encryptionField,
highRandomQualityField
) where
import qualified Data.Map as M
@ -62,9 +64,12 @@ encryptionConfigParsers =
, optionalStringParser (Accepted "keyid")
, optionalStringParser (Accepted "keyid+")
, optionalStringParser (Accepted "keyid-")
, (Accepted "highRandomQuality", \v _c -> Just . RemoteConfigValue <$> parseHighRandomQuality (fmap fromProposedAccepted v))
, (highRandomQualityField, \v _c -> Just . RemoteConfigValue <$> parseHighRandomQuality (fmap fromProposedAccepted v))
]
highRandomQualityField :: RemoteConfigField
highRandomQualityField = Accepted "highRandomQuality"
encryptionConfigs :: S.Set RemoteConfigField
encryptionConfigs = S.fromList (map fst encryptionConfigParsers)
@ -151,7 +156,7 @@ encryptionSetup c gc = do
return (storeCipher cipher c', EncryptionIsSetup)
highRandomQuality = ifM (Annex.getState Annex.fast)
( return False
, case parseHighRandomQuality (fromProposedAccepted <$> M.lookup (Accepted "highRandomQuality") c) of
, case parseHighRandomQuality (fromProposedAccepted <$> M.lookup highRandomQualityField c) of
Left err -> giveup err
Right v -> return v
)