From 3449c0e8ec7b355404644e525574212f2686d4d1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 16 Nov 2015 21:21:58 -0400 Subject: [PATCH] avoid spawning file size polling thread when not in -J mode --- Annex/Content.hs | 6 ++---- Messages/Progress.hs | 10 +++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Annex/Content.hs b/Annex/Content.hs index 90486f9128..612a96a6b1 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -660,10 +660,8 @@ saveState nocommit = doSideAction $ do {- 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 diff --git a/Messages/Progress.hs b/Messages/Progress.hs index c14e7e6b13..25d803b1b2 100644 --- a/Messages/Progress.hs +++ b/Messages/Progress.hs @@ -70,7 +70,15 @@ concurrentMetered :: Maybe MeterUpdate -> Key -> (MeterUpdate -> Annex a) -> Ann 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 ()