ci/cron/check: use whileJust_ for recursion (#7747)

As suggested in #7746.

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Gary Verhaegen 2020-10-20 16:03:46 +02:00 committed by GitHub
parent 1d638c29cb
commit cdf6160c76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -19,8 +19,9 @@ da_haskell_binary(
"http-client",
"http-client-tls",
"http-types",
"optparse-applicative",
"monad-loops",
"network-uri",
"optparse-applicative",
"process",
"regex-tdfa",
"semver",

View File

@ -12,6 +12,7 @@ import qualified Control.Concurrent.QSem
import qualified Control.Exception
import qualified Control.Monad as Control
import qualified Control.Monad.Extra
import qualified Control.Monad.Loops
import qualified Data.Aeson as JSON
import qualified Data.ByteString
import qualified Data.ByteString.UTF8 as BS
@ -285,13 +286,11 @@ download_assets tmp release = do
HTTP.withResponse req manager (\resp -> do
let body = HTTP.responseBody resp
IO.withBinaryFile (tmp </> (last $ Network.URI.pathSegments url)) IO.AppendMode (\handle -> do
let loop = do
bs <- HTTP.brRead body
if Data.ByteString.null bs then return ()
else do
Data.ByteString.hPut handle bs
loop
loop))))
while (readFrom body) (writeTo handle)))))
where while = Control.Monad.Loops.whileJust_
readFrom body = ifNotEmpty <$> HTTP.brRead body
ifNotEmpty bs = if Data.ByteString.null bs then Nothing else Just bs
writeTo = Data.ByteString.hPut
verify_signatures :: FilePath -> FilePath -> String -> IO String
verify_signatures bash_lib tmp version_tag = do