summaryrefslogtreecommitdiff
path: root/Assistant/Pairing
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-29 14:07:12 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-29 14:07:12 -0400
commit0b808465e21d667c0826f454bbe88abff79389b7 (patch)
tree4e44a4ad43cee59eca51d90721fc93cbf3d68596 /Assistant/Pairing
parent5be6ce672226df37900ddb32f29b24e6b96277a9 (diff)
Assistant monad, stage 3
All toplevel named threads are converted to the Assistant monad. Some utility functions still need to be converted.
Diffstat (limited to 'Assistant/Pairing')
-rw-r--r--Assistant/Pairing/MakeRemote.hs19
-rw-r--r--Assistant/Pairing/Network.hs4
2 files changed, 11 insertions, 12 deletions
diff --git a/Assistant/Pairing/MakeRemote.hs b/Assistant/Pairing/MakeRemote.hs
index ab0bef13c..d7e95686f 100644
--- a/Assistant/Pairing/MakeRemote.hs
+++ b/Assistant/Pairing/MakeRemote.hs
@@ -8,9 +8,6 @@
module Assistant.Pairing.MakeRemote where
import Assistant.Common
-import Assistant.ThreadedMonad
-import Assistant.DaemonStatus
-import Assistant.ScanRemotes
import Assistant.Ssh
import Assistant.Pairing
import Assistant.Pairing.Network
@@ -31,13 +28,12 @@ setupAuthorizedKeys msg = do
{- When pairing is complete, this is used to set up the remote for the host
- we paired with. -}
-finishedPairing :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> PairMsg -> SshKeyPair -> IO ()
-finishedPairing st dstatus scanremotes msg keypair = do
- sshdata <- setupSshKeyPair keypair =<< pairMsgToSshData msg
- {- Ensure that we know
- - the ssh host key for the host we paired with.
+finishedPairing :: PairMsg -> SshKeyPair -> Assistant ()
+finishedPairing msg keypair = do
+ sshdata <- liftIO $ setupSshKeyPair keypair =<< pairMsgToSshData msg
+ {- Ensure that we know the ssh host key for the host we paired with.
- If we don't, ssh over to get it. -}
- unlessM (knownHost $ sshHostName sshdata) $
+ liftIO $ unlessM (knownHost $ sshHostName sshdata) $
void $ sshTranscript
[ sshOpt "StrictHostKeyChecking" "no"
, sshOpt "NumberOfPasswordPrompts" "0"
@@ -46,7 +42,10 @@ finishedPairing st dstatus scanremotes msg keypair = do
, "git-annex-shell -c configlist " ++ T.unpack (sshDirectory sshdata)
]
""
- void $ makeSshRemote st dstatus scanremotes False sshdata
+ st <- getAssistant threadState
+ dstatus <- getAssistant daemonStatusHandle
+ scanremotes <- getAssistant scanRemoteMap
+ void $ liftIO $ makeSshRemote st dstatus scanremotes False sshdata
{- Mostly a straightforward conversion. Except:
- * Determine the best hostname to use to contact the host.
diff --git a/Assistant/Pairing/Network.hs b/Assistant/Pairing/Network.hs
index 73de9c760..3283fbc8c 100644
--- a/Assistant/Pairing/Network.hs
+++ b/Assistant/Pairing/Network.hs
@@ -87,8 +87,8 @@ startSending dstatus pip stage sender = void $ forkIO $ do
where
stopold = maybe noop killThread . inProgressThreadId
-stopSending :: DaemonStatusHandle -> PairingInProgress -> IO ()
-stopSending dstatus pip = do
+stopSending :: PairingInProgress -> DaemonStatusHandle -> IO ()
+stopSending pip dstatus = do
maybe noop killThread $ inProgressThreadId pip
modifyDaemonStatus_ dstatus $ \s -> s { pairingInProgress = Nothing }