when downloading same content from multiple urls, only display error if all fail
This commit is contained in:
parent
854cd2ad47
commit
00937c4813
1 changed files with 9 additions and 2 deletions
|
@ -807,8 +807,15 @@ downloadUrl :: Key -> MeterUpdate -> [Url.URLString] -> FilePath -> Url.UrlOptio
|
||||||
downloadUrl k p urls file uo =
|
downloadUrl k p urls file uo =
|
||||||
-- Poll the file to handle configurations where an external
|
-- Poll the file to handle configurations where an external
|
||||||
-- download command is used.
|
-- download command is used.
|
||||||
meteredFile file (Just p) k $
|
meteredFile file (Just p) k (go urls Nothing)
|
||||||
anyM (\u -> Url.download p u file uo) urls
|
where
|
||||||
|
-- Display only one error message, if all the urls fail to
|
||||||
|
-- download.
|
||||||
|
go [] (Just err) = warning err >> return False
|
||||||
|
go [] Nothing = return False
|
||||||
|
go (u:us) _ = Url.download' p u file uo >>= \case
|
||||||
|
Right () -> return True
|
||||||
|
Left err -> go us (Just err)
|
||||||
|
|
||||||
{- Copies a key's content, when present, to a temp file.
|
{- Copies a key's content, when present, to a temp file.
|
||||||
- This is used to speed up some rsyncs. -}
|
- This is used to speed up some rsyncs. -}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue