2 minor fixes to transferkeys, otherwise it was perfect 1st time!

Needed to send a trailing NUL to end a request, and set the read handle
non-blocking.

Also, set fileSystemEncoding on all handles, since there's a filename in
there.
This commit is contained in:
Joey Hess 2013-03-20 13:18:12 -04:00
parent b6d691aff7
commit 2c26bd1c65
2 changed files with 9 additions and 1 deletions

View file

@ -62,6 +62,8 @@ mkTransferrer program = do
closeFd tread
myreadh <- fdToHandle myread
mywriteh <- fdToHandle mywrite
fileEncoding myreadh
fileEncoding mywriteh
return $ Transferrer
{ transferrerRead = myreadh
, transferrerWrite = mywriteh

View file

@ -66,7 +66,12 @@ runRequests
-> Handle
-> (TransferRequest -> Annex Bool)
-> Annex ()
runRequests readh writeh a = go =<< readrequests
runRequests readh writeh a = do
liftIO $ do
hSetBuffering readh NoBuffering
fileEncoding readh
fileEncoding writeh
go =<< readrequests
where
go (d:u:k:f:rest) = do
case (deserialize d, deserialize u, deserialize k, deserialize f) of
@ -93,6 +98,7 @@ sendRequest t f h = do
, serialize (transferUUID t)
, serialize (transferKey t)
, serialize f
, "" -- adds a trailing null
]
hFlush h