separate RemoteConfig parsing basically working

Many special remotes are not updated yet and are commented out.
This commit is contained in:
Joey Hess 2020-01-14 12:35:08 -04:00
parent 71f78fe45d
commit 963239da5c
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
26 changed files with 282 additions and 212 deletions

View file

@ -1,6 +1,6 @@
{- git-annex command
-
- Copyright 2014-2019 Joey Hess <id@joeyh.name>
- Copyright 2014-2020 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -25,8 +25,11 @@ import Utility.CopyFile
import Types.Messages
import Types.Export
import Types.ProposedAccepted
import Types.Crypto
import Types.RemoteConfig
import Remote.Helper.ExportImport
import Remote.Helper.Chunked
import Remote.Helper.Encryptable (describeEncryption)
import Git.Types
import Test.Tasty
@ -110,7 +113,7 @@ perform rs unavailrs exportr ks = do
desc r' k = intercalate "; " $ map unwords
[ [ "key size", show (fromKey keySize k) ]
, [ show (getChunkConfig (Remote.config r')) ]
, ["encryption", maybe "none" fromProposedAccepted (M.lookup (Accepted "encryption") (Remote.config r'))]
, ["encryption", describeEncryption (Remote.config r')]
]
descexport k1 k2 = intercalate "; " $ map unwords
[ [ "exporttree=yes" ]
@ -120,16 +123,17 @@ perform rs unavailrs exportr ks = do
adjustChunkSize :: Remote -> Int -> Annex (Maybe Remote)
adjustChunkSize r chunksize = adjustRemoteConfig r
(M.insert (Proposed "chunk") (Proposed (show chunksize)))
(M.insert (Proposed "chunk") (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") (Proposed "none"))
noenc <- adjustRemoteConfig r $
M.insert (Proposed "encryption") (RemoteConfigValue NoneEncryption)
sharedenc <- adjustRemoteConfig r $
M.insert (Proposed "encryption") (Proposed "shared") .
M.insert (Proposed "highRandomQuality") (Proposed "false")
M.insert (Proposed "encryption") (RemoteConfigValue SharedEncryption) .
M.insert (Proposed "highRandomQuality") (RemoteConfigValue False)
return $ catMaybes [noenc, sharedenc]
-- Variant of a remote with exporttree disabled.
@ -141,13 +145,13 @@ 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") (Proposed "none") .
M.insert (Proposed "exporttree") (Proposed "yes")
M.insert (Proposed "encryption") (RemoteConfigValue NoneEncryption) .
M.insert (Proposed "exporttree") (RemoteConfigValue True)
, return Nothing
)
-- Regenerate a remote with a modified config.
adjustRemoteConfig :: Remote -> (Remote.RemoteConfig -> Remote.RemoteConfig) -> Annex (Maybe Remote)
adjustRemoteConfig :: Remote -> (Remote.ParsedRemoteConfig -> Remote.ParsedRemoteConfig) -> Annex (Maybe Remote)
adjustRemoteConfig r adjustconfig = do
repo <- Remote.getRepo r
Remote.generate (Remote.remotetype r)