summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-02-07 14:35:58 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-02-07 14:55:58 -0400
commitdc0f824c1bc4c9aac1045894983a434eb26196ab (patch)
treea84543bd5ea46c8655fdd189f148f8bab9e48664 /Assistant
parent2d5e728c407f5d3447365211a64b088700834787 (diff)
add SetupStage parameter to RemoteType.setup
Most remotes have an idempotent setup that can be reused for enableremote, but in a few cases, it needs to tell which, and whether a UUID was provided to setup was used. This is groundwork for making initremote be able to provide a UUID. It should not change any behavior. Note that it would be nice to make the UUID always be provided to setup, and make setup not need to generate and return a UUID. What prevented this simplification is Remote.Git.gitSetup, which needs to reuse the UUID of the git remote when setting it up, and so has to return that UUID. This commit was sponsored by Thom May on Patreon.
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/MakeRemote.hs16
1 files changed, 8 insertions, 8 deletions
diff --git a/Assistant/MakeRemote.hs b/Assistant/MakeRemote.hs
index a5972b0d8..6d0377206 100644
--- a/Assistant/MakeRemote.hs
+++ b/Assistant/MakeRemote.hs
@@ -49,9 +49,9 @@ makeRsyncRemote name location = makeRemote name location $ const $ void $
go =<< Annex.SpecialRemote.findExisting name
where
go Nothing = setupSpecialRemote name Rsync.remote config Nothing
- (Nothing, Annex.SpecialRemote.newConfig name)
+ (Nothing, R.Init, Annex.SpecialRemote.newConfig name)
go (Just (u, c)) = setupSpecialRemote name Rsync.remote config Nothing
- (Just u, c)
+ (Just u, R.Enable, c)
config = M.fromList
[ ("encryption", "shared")
, ("rsyncurl", location)
@@ -81,7 +81,7 @@ initSpecialRemote name remotetype mcreds config = go 0
r <- Annex.SpecialRemote.findExisting fullname
case r of
Nothing -> setupSpecialRemote fullname remotetype config mcreds
- (Nothing, Annex.SpecialRemote.newConfig fullname)
+ (Nothing, R.Init, Annex.SpecialRemote.newConfig fullname)
Just _ -> go (n + 1)
{- Enables an existing special remote. -}
@@ -90,19 +90,19 @@ enableSpecialRemote name remotetype mcreds config = do
r <- Annex.SpecialRemote.findExisting name
case r of
Nothing -> error $ "Cannot find a special remote named " ++ name
- Just (u, c) -> setupSpecialRemote' False name remotetype config mcreds (Just u, c)
+ Just (u, c) -> setupSpecialRemote' False name remotetype config mcreds (Just u, R.Enable, c)
-setupSpecialRemote :: RemoteName -> RemoteType -> R.RemoteConfig -> Maybe CredPair -> (Maybe UUID, R.RemoteConfig) -> Annex RemoteName
+setupSpecialRemote :: RemoteName -> RemoteType -> R.RemoteConfig -> Maybe CredPair -> (Maybe UUID, R.SetupStage, R.RemoteConfig) -> Annex RemoteName
setupSpecialRemote = setupSpecialRemote' True
-setupSpecialRemote' :: Bool -> RemoteName -> RemoteType -> R.RemoteConfig -> Maybe CredPair -> (Maybe UUID, R.RemoteConfig) -> Annex RemoteName
-setupSpecialRemote' setdesc name remotetype config mcreds (mu, c) = do
+setupSpecialRemote' :: Bool -> RemoteName -> RemoteType -> R.RemoteConfig -> Maybe CredPair -> (Maybe UUID, R.SetupStage, R.RemoteConfig) -> Annex RemoteName
+setupSpecialRemote' setdesc name remotetype config mcreds (mu, ss, c) = do
{- Currently, only 'weak' ciphers can be generated from the
- assistant, because otherwise GnuPG may block once the entropy
- pool is drained, and as of now there's no way to tell the user
- to perform IO actions to refill the pool. -}
let weakc = M.insert "highRandomQuality" "false" $ M.union config c
- (c', u) <- R.setup remotetype mu mcreds weakc def
+ (c', u) <- R.setup remotetype ss mu mcreds weakc def
configSet u c'
when setdesc $
whenM (isNothing . M.lookup u <$> uuidMap) $