send remote-daemon a RELOAD after making a ssh remote

This doesn't work yet, because RELOAD is buggy and does not notice the new
remote.
This commit is contained in:
Joey Hess 2014-04-20 15:30:39 -04:00
parent 1a4c3caa96
commit 512da29273
4 changed files with 24 additions and 10 deletions

View file

@ -52,8 +52,10 @@ remoteControlThread = namedThread "RemoteControl" $ do
remoteControllerThread :: Handle -> Assistant () remoteControllerThread :: Handle -> Assistant ()
remoteControllerThread toh = do remoteControllerThread toh = do
clicker <- getAssistant remoteControl clicker <- getAssistant remoteControl
liftIO $ forever $ do forever $ do
msg <- readChan clicker msg <- liftIO $ readChan clicker
debug [show msg]
liftIO $ do
hPutStrLn toh $ unwords $ formatMessage msg hPutStrLn toh $ unwords $ formatMessage msg
hFlush toh hFlush toh
@ -63,6 +65,7 @@ remoteResponderThread fromh urimap = go M.empty
where where
go syncalerts = do go syncalerts = do
l <- liftIO $ hGetLine fromh l <- liftIO $ hGetLine fromh
debug [l]
case parseMessage l of case parseMessage l of
Just (CONNECTED uri) -> changeconnected S.insert uri Just (CONNECTED uri) -> changeconnected S.insert uri
Just (DISCONNECTED uri) -> changeconnected S.delete uri Just (DISCONNECTED uri) -> changeconnected S.delete uri

View file

@ -24,6 +24,7 @@ import Git.Types (RemoteName)
import qualified Remote.GCrypt as GCrypt import qualified Remote.GCrypt as GCrypt
import Annex.UUID import Annex.UUID
import Logs.UUID import Logs.UUID
import Assistant.RemoteControl
#ifdef mingw32_HOST_OS #ifdef mingw32_HOST_OS
import Utility.Tmp import Utility.Tmp
@ -405,12 +406,19 @@ prepSsh' newgcrypt origsshdata sshdata keypair a = sshSetup
makeSshRepo :: SshData -> Handler Html makeSshRepo :: SshData -> Handler Html
makeSshRepo sshdata makeSshRepo sshdata
| onlyCapability sshdata RsyncCapable = setupCloudRemote TransferGroup Nothing go | onlyCapability sshdata RsyncCapable = setupCloudRemote TransferGroup Nothing go
| otherwise = setupRemote EditNewRepositoryR TransferGroup Nothing go | otherwise = makeSshRepoConnection go
where where
go = makeSshRemote sshdata go = makeSshRemote sshdata
makeSshRepoConnection :: Annex RemoteName -> Handler Html
makeSshRepoConnection a = setupRemote postsetup TransferGroup Nothing a
where
postsetup u = do
liftAssistant $ sendRemoteControl RELOAD
redirect $ EditNewRepositoryR u
makeGCryptRepo :: KeyId -> SshData -> Handler Html makeGCryptRepo :: KeyId -> SshData -> Handler Html
makeGCryptRepo keyid sshdata = setupRemote EditNewRepositoryR TransferGroup Nothing $ makeGCryptRepo keyid sshdata = makeSshRepoConnection $
makeGCryptRemote (sshRepoName sshdata) (genSshUrl sshdata) keyid makeGCryptRemote (sshRepoName sshdata) (genSshUrl sshdata) keyid
getAddRsyncNetR :: Handler Html getAddRsyncNetR :: Handler Html

View file

@ -31,13 +31,13 @@ import Utility.Yesod
- This includes displaying the connectionNeeded nudge if appropariate. - This includes displaying the connectionNeeded nudge if appropariate.
-} -}
setupCloudRemote :: StandardGroup -> Maybe Cost -> Annex RemoteName -> Handler a setupCloudRemote :: StandardGroup -> Maybe Cost -> Annex RemoteName -> Handler a
setupCloudRemote = setupRemote EditNewCloudRepositoryR setupCloudRemote = setupRemote $ redirect . EditNewCloudRepositoryR
setupRemote :: (UUID -> Route WebApp) -> StandardGroup -> Maybe Cost -> Annex RemoteName -> Handler a setupRemote :: (UUID -> Handler a) -> StandardGroup -> Maybe Cost -> Annex RemoteName -> Handler a
setupRemote redirto defaultgroup mcost getname = do setupRemote postsetup defaultgroup mcost getname = do
r <- liftAnnex $ addRemote getname r <- liftAnnex $ addRemote getname
liftAnnex $ do liftAnnex $ do
setStandardGroup (Remote.uuid r) defaultgroup setStandardGroup (Remote.uuid r) defaultgroup
maybe noop (Config.setRemoteCost (Remote.repo r)) mcost maybe noop (Config.setRemoteCost (Remote.repo r)) mcost
liftAssistant $ syncRemote r liftAssistant $ syncRemote r
redirect $ redirto $ Remote.uuid r postsetup $ Remote.uuid r

View file

@ -20,6 +20,7 @@ import Control.Concurrent
-- The URI of a remote is used to uniquely identify it (names change..) -- The URI of a remote is used to uniquely identify it (names change..)
newtype RemoteURI = RemoteURI URI newtype RemoteURI = RemoteURI URI
deriving (Show)
-- A Transport for a particular git remote consumes some messages -- A Transport for a particular git remote consumes some messages
-- from a Chan, and emits others to another Chan. -- from a Chan, and emits others to another Chan.
@ -38,6 +39,7 @@ data Emitted
| SYNCING RemoteURI | SYNCING RemoteURI
| DONESYNCING RemoteURI Bool | DONESYNCING RemoteURI Bool
| WARNING RemoteURI String | WARNING RemoteURI String
deriving (Show)
-- Messages that the deamon consumes. -- Messages that the deamon consumes.
data Consumed data Consumed
@ -47,6 +49,7 @@ data Consumed
| CHANGED RefList | CHANGED RefList
| RELOAD | RELOAD
| STOP | STOP
deriving (Show)
type RefList = [Git.Ref] type RefList = [Git.Ref]