{- Downloads content from any of a list of urls. -}
downloadUrl :: Key -> MeterUpdate -> [Url.URLString] -> FilePath -> Annex Bool
-downloadUrl k p urls file =
- concurrentMetered (Just p) k $ \p' ->
- watchFileSize file p' $
- go =<< annexWebDownloadCommand <$> Annex.getGitConfig
+downloadUrl k p urls file = concurrentMeteredFile file (Just p) k $
+ go =<< annexWebDownloadCommand <$> Annex.getGitConfig
where
go Nothing = do
a <- ifM commandProgressDisabled
concurrentMetered combinemeterupdate key a = withOutputType go
where
go (ConcurrentOutput _) = metered combinemeterupdate key a
- go _ = a (fromMaybe (const noop) combinemeterupdate)
+ go _ = a (fromMaybe nullMeterUpdate combinemeterupdate)
+
+{- Poll file size to display meter, but only for concurrent output. -}
+concurrentMeteredFile :: FilePath -> Maybe MeterUpdate -> Key -> Annex a -> Annex a
+concurrentMeteredFile file combinemeterupdate key a = withOutputType go
+ where
+ go (ConcurrentOutput _) = metered combinemeterupdate key $ \p ->
+ watchFileSize file p a
+ go _ = a
{- Progress dots. -}
showProgressDots :: Annex ()