summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-04-08 14:02:25 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-04-08 14:02:25 -0400
commit9b09962ee86ec7531d7ca946e62ccf6a48a67399 (patch)
tree13449e83e80b6e1b788c0e0996b0412038579340 /Command
parentf2426676defafecc904234de3522f57ebf7ab19d (diff)
remotedaemon: avoid extraneous stdout output
Diffstat (limited to 'Command')
-rw-r--r--Command/TransferKeys.hs21
1 files changed, 3 insertions, 18 deletions
diff --git a/Command/TransferKeys.hs b/Command/TransferKeys.hs
index 8f4498eb1..05129005b 100644
--- a/Command/TransferKeys.hs
+++ b/Command/TransferKeys.hs
@@ -16,8 +16,7 @@ import Logs.Location
import Annex.Transfer
import qualified Remote
import Types.Key
-
-import GHC.IO.Handle
+import Utility.SimpleProtocol (ioHandles)
data TransferRequest = TransferRequest Direction Remote Key AssociatedFile
@@ -29,7 +28,8 @@ seek :: CommandSeek
seek = withNothing start
start :: CommandStart
-start = withHandles $ \(readh, writeh) -> do
+start = do
+ (readh, writeh) <- liftIO ioHandles
runRequests readh writeh runner
stop
where
@@ -44,21 +44,6 @@ start = withHandles $ \(readh, writeh) -> do
download (Remote.uuid remote) key file forwardRetry $ \p ->
getViaTmp key $ \t -> Remote.retrieveKeyFile remote key file t p
-{- stdin and stdout are connected with the caller, to be used for
- - communication with it. But doing a transfer might involve something
- - that tries to read from stdin, or write to stdout. To avoid that, close
- - stdin, and duplicate stderr to stdout. Return two new handles
- - that are duplicates of the original (stdin, stdout). -}
-withHandles :: ((Handle, Handle) -> Annex a) -> Annex a
-withHandles a = do
- readh <- liftIO $ hDuplicate stdin
- writeh <- liftIO $ hDuplicate stdout
- liftIO $ do
- nullh <- openFile devNull ReadMode
- nullh `hDuplicateTo` stdin
- stderr `hDuplicateTo` stdout
- a (readh, writeh)
-
runRequests
:: Handle
-> Handle