separate RemoteConfig parsing basically working
Many special remotes are not updated yet and are commented out.
This commit is contained in:
parent
71f78fe45d
commit
963239da5c
26 changed files with 282 additions and 212 deletions
|
@ -1,6 +1,6 @@
|
|||
{- A remote that is only accessible by rsync.
|
||||
-
|
||||
- Copyright 2011-2018 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2011-2020 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -42,20 +42,31 @@ import Types.Creds
|
|||
import Annex.DirHashes
|
||||
import Utility.Tmp.Dir
|
||||
import Utility.SshHost
|
||||
import Annex.SpecialRemote.Config
|
||||
|
||||
import qualified Data.Map as M
|
||||
|
||||
remote :: RemoteType
|
||||
remote = RemoteType
|
||||
remote = specialRemoteType $ RemoteType
|
||||
{ typename = "rsync"
|
||||
, enumerate = const (findSpecialRemotes "rsyncurl")
|
||||
, generate = gen
|
||||
, configParser =
|
||||
[ yesNoParser shellEscapeField True
|
||||
, optionalStringParser rsyncUrlField
|
||||
]
|
||||
, setup = rsyncSetup
|
||||
, exportSupported = exportIsSupported
|
||||
, importSupported = importUnsupported
|
||||
}
|
||||
|
||||
gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
|
||||
shellEscapeField :: RemoteConfigField
|
||||
shellEscapeField = Accepted "shellescape"
|
||||
|
||||
rsyncUrlField :: RemoteConfigField
|
||||
rsyncUrlField = Accepted "rsyncurl"
|
||||
|
||||
gen :: Git.Repo -> UUID -> ParsedRemoteConfig -> RemoteGitConfig -> RemoteStateHandle -> Annex (Maybe Remote)
|
||||
gen r u c gc rs = do
|
||||
cst <- remoteCost gc expensiveRemoteCost
|
||||
(transport, url) <- rsyncTransport gc $
|
||||
|
@ -112,7 +123,7 @@ gen r u c gc rs = do
|
|||
-- Rsync displays its own progress.
|
||||
{ displayProgress = False }
|
||||
|
||||
genRsyncOpts :: RemoteConfig -> RemoteGitConfig -> Annex [CommandParam] -> RsyncUrl -> RsyncOpts
|
||||
genRsyncOpts :: ParsedRemoteConfig -> RemoteGitConfig -> Annex [CommandParam] -> RsyncUrl -> RsyncOpts
|
||||
genRsyncOpts c gc transport url = RsyncOpts
|
||||
{ rsyncUrl = url
|
||||
, rsyncOptions = appendtransport $ opts []
|
||||
|
@ -120,7 +131,7 @@ genRsyncOpts c gc transport url = RsyncOpts
|
|||
opts (remoteAnnexRsyncUploadOptions gc)
|
||||
, rsyncDownloadOptions = appendtransport $
|
||||
opts (remoteAnnexRsyncDownloadOptions gc)
|
||||
, rsyncShellEscape = (yesNo . fromProposedAccepted =<< M.lookup (Accepted "shellescape") c) /= Just False
|
||||
, rsyncShellEscape = fromMaybe True (getRemoteConfigValue shellEscapeField c)
|
||||
}
|
||||
where
|
||||
appendtransport l = (++ l) <$> transport
|
||||
|
@ -163,10 +174,7 @@ rsyncSetup _ mu _ c gc = do
|
|||
u <- maybe (liftIO genUUID) return mu
|
||||
-- verify configuration is sane
|
||||
let url = maybe (giveup "Specify rsyncurl=") fromProposedAccepted $
|
||||
M.lookup (Accepted "rsyncurl") c
|
||||
case parseProposedAccepted (Accepted "shellescape") c yesNo False "yes or no" of
|
||||
Left err -> giveup err
|
||||
_ -> noop
|
||||
M.lookup rsyncUrlField c
|
||||
(c', _encsetup) <- encryptionSetup c gc
|
||||
|
||||
-- The rsyncurl is stored in git config, not only in this remote's
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue