diff --git a/Command/TestRemote.hs b/Command/TestRemote.hs index d403e6d802..7e56e25181 100644 --- a/Command/TestRemote.hs +++ b/Command/TestRemote.hs @@ -24,13 +24,12 @@ import Utility.DataUnits import Utility.CopyFile import Types.Messages import Types.Export -import Types.ProposedAccepted import Types.Crypto import Types.RemoteConfig import Annex.SpecialRemote.Config (exportTreeField) import Remote.Helper.ExportImport import Remote.Helper.Chunked -import Remote.Helper.Encryptable (describeEncryption) +import Remote.Helper.Encryptable (describeEncryption, encryptionField, highRandomQualityField) import Git.Types import Test.Tasty @@ -124,17 +123,17 @@ perform rs unavailrs exportr ks = do adjustChunkSize :: Remote -> Int -> Annex (Maybe Remote) adjustChunkSize r chunksize = adjustRemoteConfig r - (M.insert (Proposed "chunk") (RemoteConfigValue (show chunksize))) + (M.insert chunkField (RemoteConfigValue (show chunksize))) -- Variants of a remote with no encryption, and with simple shared -- encryption. Gpg key based encryption is not tested. encryptionVariants :: Remote -> Annex [Remote] encryptionVariants r = do noenc <- adjustRemoteConfig r $ - M.insert (Proposed "encryption") (RemoteConfigValue NoneEncryption) + M.insert encryptionField (RemoteConfigValue NoneEncryption) sharedenc <- adjustRemoteConfig r $ - M.insert (Proposed "encryption") (RemoteConfigValue SharedEncryption) . - M.insert (Proposed "highRandomQuality") (RemoteConfigValue False) + M.insert encryptionField (RemoteConfigValue SharedEncryption) . + M.insert highRandomQualityField (RemoteConfigValue False) return $ catMaybes [noenc, sharedenc] -- Variant of a remote with exporttree disabled. @@ -146,8 +145,8 @@ disableExportTree r = maybe (error "failed disabling exportree") return exportTreeVariant :: Remote -> Annex (Maybe Remote) exportTreeVariant r = ifM (Remote.isExportSupported r) ( adjustRemoteConfig r $ - M.insert (Proposed "encryption") (RemoteConfigValue NoneEncryption) . - M.insert (Proposed "exporttree") (RemoteConfigValue True) + M.insert encryptionField (RemoteConfigValue NoneEncryption) . + M.insert exportTreeField (RemoteConfigValue True) , return Nothing ) diff --git a/Remote/Helper/Chunked.hs b/Remote/Helper/Chunked.hs index 7fc11283d9..9a4f9f0c5f 100644 --- a/Remote/Helper/Chunked.hs +++ b/Remote/Helper/Chunked.hs @@ -16,6 +16,7 @@ module Remote.Helper.Chunked ( removeChunks, retrieveChunks, checkPresentChunks, + chunkField, ) where import Annex.Common diff --git a/Remote/Helper/Encryptable.hs b/Remote/Helper/Encryptable.hs index 714a12f279..e5311dce73 100644 --- a/Remote/Helper/Encryptable.hs +++ b/Remote/Helper/Encryptable.hs @@ -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 )