diff options
author | Joey Hess <joey@kitenet.net> | 2012-11-09 23:17:47 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-11-09 23:17:47 -0400 |
commit | d166b4d35bdd3fcd0f3cef9c562dfa18f96b56bf (patch) | |
tree | aaacb20581680fa6d87e67082959f34e22c34521 /Assistant/XMPP | |
parent | 45538c7c87016d9fab4b498fa1ac2aec186cc677 (diff) |
refactor
Diffstat (limited to 'Assistant/XMPP')
-rw-r--r-- | Assistant/XMPP/Git.hs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Assistant/XMPP/Git.hs b/Assistant/XMPP/Git.hs index 94ec644df..fc32698ae 100644 --- a/Assistant/XMPP/Git.hs +++ b/Assistant/XMPP/Git.hs @@ -233,25 +233,24 @@ xmppRemotes cid = case baseJID <$> parseJID cid of let r = Remote.repo remote return $ repoIsUrl r && repoLocation r == "xmpp::" ++ want -handleDeferred :: NetMessage -> Assistant () -handleDeferred = handlePushMessage +whenXMPPRemote :: ClientID -> Assistant () -> Assistant () +whenXMPPRemote cid = unlessM (null <$> xmppRemotes cid) handlePushMessage :: NetMessage -> Assistant () -handlePushMessage (CanPush cid) = do - rs <- xmppRemotes cid - unless (null rs) $ - sendNetMessage $ PushRequest cid +handlePushMessage (CanPush cid) = whenXMPPRemote cid $ + sendNetMessage $ PushRequest cid handlePushMessage (PushRequest cid) = do rs <- xmppRemotes cid current <- liftAnnex $ inRepo Git.Branch.current --let refs = catMaybes [current, Just Annex.Branch.fullname] -- TODO let refs = [Ref "master:refs/xmpp/newmaster"] forM_ rs $ \r -> xmppPush cid r refs -handlePushMessage (StartingPush cid) = do - rs <- xmppRemotes cid - unless (null rs) $ - void $ xmppReceivePack cid +handlePushMessage (StartingPush cid) = whenXMPPRemote cid $ + void $ xmppReceivePack cid handlePushMessage _ = noop +handleDeferred :: NetMessage -> Assistant () +handleDeferred = handlePushMessage + chunkSize :: Int chunkSize = 1024 |