converted reads from stderr to use hGetLineUntilExitOrEOF

These are all unlikely to suffer from the inherited stderr fd problem,
but who knows, it could happen.
This commit is contained in:
Joey Hess 2020-11-19 16:21:17 -04:00
parent 613455e059
commit ff0927bde9
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 27 additions and 15 deletions

View file

@ -225,16 +225,19 @@ youtubeDlFileNameHtmlOnly' url uo
liftIO $ withCreateProcess p waitproc
waitproc Nothing (Just o) (Just e) pid = do
output <- fmap fst $
hGetContentsStrict o
`concurrently`
hGetContentsStrict e
errt <- async $ discardstderr pid e
output <- hGetContentsStrict o
ok <- liftIO $ checkSuccessProcess pid
wait errt
return $ case (ok, lines output) of
(True, (f:_)) | not (null f) -> Right f
_ -> nomedia
waitproc _ _ _ _ = error "internal"
discardstderr pid e = hGetLineUntilExitOrEOF pid e >>= \case
Nothing -> return ()
Just _ -> discardstderr pid e
nomedia = Left "no media in url"
youtubeDlOpts :: [CommandParam] -> Annex [CommandParam]