From dc0f824c1bc4c9aac1045894983a434eb26196ab Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 7 Feb 2017 14:35:58 -0400 Subject: 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. --- Assistant/MakeRemote.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Assistant/MakeRemote.hs') 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) $ -- cgit v1.2.3