]> dgit.raspbian.org Git - git-annex.git/commitdiff
refactor
authorJoey Hess <joeyh@joeyh.name>
Thu, 10 Dec 2020 20:33:52 +0000 (16:33 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 10 Dec 2020 20:33:52 +0000 (16:33 -0400)
Command/Transferrer.hs

index 5222011c9506d18a638c37c27bafd528711d98f9..410a4de6561ecaece2eb085951a0bf1cea3e346a 100644 (file)
@@ -32,10 +32,7 @@ start :: CommandStart
 start = do
        enableInteractiveBranchAccess
        (readh, writeh) <- liftIO dupIoHandles
-       let outputwriter v = do
-               hPutStrLn writeh $
-                       unwords $ Proto.formatMessage $ TransferOutput v
-               hFlush writeh
+       let outputwriter = sendTransferResponse writeh . TransferOutput
        let outputresponsereader = do
                l <- hGetLine readh
                return $ case Proto.parseMessage l of
@@ -114,7 +111,9 @@ runRequests readh writeh a = go Nothing Nothing
                                        Nothing -> transferrerProtocolError l
                        Nothing -> transferrerProtocolError l
 
-       sendresult b = liftIO $ do
-               hPutStrLn writeh $
-                       unwords $ Proto.formatMessage $ TransferResult b
-               hFlush writeh
+       sendresult = liftIO . sendTransferResponse writeh . TransferResult
+
+sendTransferResponse :: Handle -> TransferResponse -> IO ()
+sendTransferResponse h r = do
+       hPutStrLn h $ unwords $ Proto.formatMessage r
+       hFlush h