add alerts while performing xmpp git push/pull

This commit is contained in:
Joey Hess 2013-03-07 02:38:57 -04:00
parent 57b601e384
commit ade57af9e5

View file

@ -250,12 +250,9 @@ xmppRemotes cid = case baseJID <$> parseJID cid of
where where
matching loc r = repoIsUrl r && repoLocation r == loc matching loc r = repoIsUrl r && repoLocation r == loc
whenXMPPRemote :: ClientID -> Assistant () -> Assistant ()
whenXMPPRemote cid = unlessM (null <$> xmppRemotes cid)
handlePushInitiation :: NetMessage -> Assistant () handlePushInitiation :: NetMessage -> Assistant ()
handlePushInitiation (Pushing cid CanPush) = handlePushInitiation (Pushing cid CanPush) =
whenXMPPRemote cid $ unlessM (null <$> xmppRemotes cid) $
sendNetMessage $ Pushing cid PushRequest sendNetMessage $ Pushing cid PushRequest
handlePushInitiation (Pushing cid PushRequest) = handlePushInitiation (Pushing cid PushRequest) =
go =<< liftAnnex (inRepo Git.Branch.current) go =<< liftAnnex (inRepo Git.Branch.current)
@ -268,12 +265,14 @@ handlePushInitiation (Pushing cid PushRequest) =
<$> gitRepo <$> gitRepo
<*> getUUID <*> getUUID
liftIO $ Command.Sync.updateBranch (Command.Sync.syncBranch branch) g liftIO $ Command.Sync.updateBranch (Command.Sync.syncBranch branch) g
debug ["pushing to", show rs]
selfjid <- ((T.unpack <$>) . xmppClientID) <$> getDaemonStatus selfjid <- ((T.unpack <$>) . xmppClientID) <$> getDaemonStatus
forM_ rs $ \r -> xmppPush cid $ taggedPush u selfjid branch r forM_ rs $ \r -> alertWhile (syncAlert [r]) $
handlePushInitiation (Pushing cid StartingPush) = xmppPush cid $ taggedPush u selfjid branch r
whenXMPPRemote cid $ handlePushInitiation (Pushing cid StartingPush) = do
void $ xmppReceivePack cid rs <- xmppRemotes cid
unless (null rs) $
void $ alertWhile (syncAlert rs) $
xmppReceivePack cid
handlePushInitiation _ = noop handlePushInitiation _ = noop
handleDeferred :: NetMessage -> Assistant () handleDeferred :: NetMessage -> Assistant ()