mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
ci/cron/check: use whileJust_ for recursion (#7747)
As suggested in #7746. CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
1d638c29cb
commit
cdf6160c76
@ -19,8 +19,9 @@ da_haskell_binary(
|
|||||||
"http-client",
|
"http-client",
|
||||||
"http-client-tls",
|
"http-client-tls",
|
||||||
"http-types",
|
"http-types",
|
||||||
"optparse-applicative",
|
"monad-loops",
|
||||||
"network-uri",
|
"network-uri",
|
||||||
|
"optparse-applicative",
|
||||||
"process",
|
"process",
|
||||||
"regex-tdfa",
|
"regex-tdfa",
|
||||||
"semver",
|
"semver",
|
||||||
|
@ -12,6 +12,7 @@ import qualified Control.Concurrent.QSem
|
|||||||
import qualified Control.Exception
|
import qualified Control.Exception
|
||||||
import qualified Control.Monad as Control
|
import qualified Control.Monad as Control
|
||||||
import qualified Control.Monad.Extra
|
import qualified Control.Monad.Extra
|
||||||
|
import qualified Control.Monad.Loops
|
||||||
import qualified Data.Aeson as JSON
|
import qualified Data.Aeson as JSON
|
||||||
import qualified Data.ByteString
|
import qualified Data.ByteString
|
||||||
import qualified Data.ByteString.UTF8 as BS
|
import qualified Data.ByteString.UTF8 as BS
|
||||||
@ -285,13 +286,11 @@ download_assets tmp release = do
|
|||||||
HTTP.withResponse req manager (\resp -> do
|
HTTP.withResponse req manager (\resp -> do
|
||||||
let body = HTTP.responseBody resp
|
let body = HTTP.responseBody resp
|
||||||
IO.withBinaryFile (tmp </> (last $ Network.URI.pathSegments url)) IO.AppendMode (\handle -> do
|
IO.withBinaryFile (tmp </> (last $ Network.URI.pathSegments url)) IO.AppendMode (\handle -> do
|
||||||
let loop = do
|
while (readFrom body) (writeTo handle)))))
|
||||||
bs <- HTTP.brRead body
|
where while = Control.Monad.Loops.whileJust_
|
||||||
if Data.ByteString.null bs then return ()
|
readFrom body = ifNotEmpty <$> HTTP.brRead body
|
||||||
else do
|
ifNotEmpty bs = if Data.ByteString.null bs then Nothing else Just bs
|
||||||
Data.ByteString.hPut handle bs
|
writeTo = Data.ByteString.hPut
|
||||||
loop
|
|
||||||
loop))))
|
|
||||||
|
|
||||||
verify_signatures :: FilePath -> FilePath -> String -> IO String
|
verify_signatures :: FilePath -> FilePath -> String -> IO String
|
||||||
verify_signatures bash_lib tmp version_tag = do
|
verify_signatures bash_lib tmp version_tag = do
|
||||||
|
Loading…
Reference in New Issue
Block a user