a few more field functions
This commit is contained in:
parent
2edf0506a5
commit
6a982e38eb
3 changed files with 15 additions and 10 deletions
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ module Remote.Helper.Chunked (
|
|||
removeChunks,
|
||||
retrieveChunks,
|
||||
checkPresentChunks,
|
||||
chunkField,
|
||||
) where
|
||||
|
||||
import Annex.Common
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue