fix breakage in wormhole's sendFile
Commit ff0927bde9
broke this, it made it
try to read all of the input before looking for the code. But, wormhole
keeps running until it sends the file, so that caused a deadlock. Oops.
Sponsored-by: Luke Shumaker on Patreon
This commit is contained in:
parent
17129fed66
commit
f1c85ac11b
1 changed files with 9 additions and 4 deletions
|
@ -120,16 +120,21 @@ sendFile f (CodeObserver observer) ps = do
|
||||||
return (inout || inerr)
|
return (inout || inerr)
|
||||||
where
|
where
|
||||||
p = wormHoleProcess (ps ++ [Param "send", File f])
|
p = wormHoleProcess (ps ++ [Param "send", File f])
|
||||||
findcode ph h = findcode' =<< getwords ph h []
|
findcode ph h = hGetLineUntilExitOrEOF ph h >>= \case
|
||||||
|
Nothing -> return False
|
||||||
|
Just l -> ifM (findcode' (words l))
|
||||||
|
( drain ph h >> return True
|
||||||
|
, findcode ph h
|
||||||
|
)
|
||||||
findcode' [] = return False
|
findcode' [] = return False
|
||||||
findcode' (w:ws) = case mkCode w of
|
findcode' (w:ws) = case mkCode w of
|
||||||
Just code -> do
|
Just code -> do
|
||||||
_ <- tryPutMVar observer code
|
_ <- tryPutMVar observer code
|
||||||
return True
|
return True
|
||||||
Nothing -> findcode' ws
|
Nothing -> findcode' ws
|
||||||
getwords ph h c = hGetLineUntilExitOrEOF ph h >>= \case
|
drain ph h = hGetLineUntilExitOrEOF ph h >>= \case
|
||||||
Nothing -> return $ concatMap words $ reverse c
|
Just _ -> drain ph h
|
||||||
Just l -> getwords ph h (l:c)
|
Nothing -> return ()
|
||||||
|
|
||||||
-- | Receives a file. Once the receive is under way, the Code will be
|
-- | Receives a file. Once the receive is under way, the Code will be
|
||||||
-- read from the CodeProducer, and fed to wormhole on stdin.
|
-- read from the CodeProducer, and fed to wormhole on stdin.
|
||||||
|
|
Loading…
Reference in a new issue