summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-11-10 00:24:26 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-11-10 00:24:26 -0400
commitcda928f8224ca900d5af9e923a3d39fe57824636 (patch)
tree67e271debac0abbc77f112fa7a4fccce71cd549c
parentf552237297c92b42c647dd7d54ab3d0b7d7030e6 (diff)
refactor
-rw-r--r--Assistant/XMPP/Git.hs16
1 files changed, 8 insertions, 8 deletions
diff --git a/Assistant/XMPP/Git.hs b/Assistant/XMPP/Git.hs
index c47e14b22..49d3bedcc 100644
--- a/Assistant/XMPP/Git.hs
+++ b/Assistant/XMPP/Git.hs
@@ -122,9 +122,7 @@ xmppPush cid remote refs = runPush (SendPushRunning cid) handleDeferred $ do
fromxmpp outh controlh = forever $ do
m <- waitNetPushMessage
case m of
- (ReceivePackOutput _ b) -> liftIO $ do
- B.hPut outh b
- hFlush outh
+ (ReceivePackOutput _ b) -> liftIO $ writeChunk outh b
(ReceivePackDone _ exitcode) -> liftIO $ do
hPrint controlh exitcode
hFlush controlh
@@ -183,8 +181,7 @@ xmppGitRelay = do
hClose fromh
hClose toh
killThread =<< myThreadId
- B.hPut toh b
- hFlush toh
+ writeChunk toh b
{- Relays git receive-pack stdin and stdout via XMPP, as well as propigating
- its exit status to XMPP. -}
@@ -216,9 +213,7 @@ xmppReceivePack cid = runPush (ReceivePushRunning cid) handleDeferred $ do
relayfromxmpp inh = forever $ do
m <- waitNetPushMessage
case m of
- (SendPackOutput _ b) -> liftIO $ do
- B.hPut inh b
- hFlush inh
+ (SendPackOutput _ b) -> liftIO $ writeChunk inh b
_ -> noop
xmppRemotes :: ClientID -> Assistant [Remote]
@@ -252,3 +247,8 @@ handleDeferred = handlePushMessage
chunkSize :: Int
chunkSize = 4096
+
+writeChunk :: Handle -> B.ByteString -> IO ()
+writeChunk h b = do
+ B.hPut h b
+ hFlush h