avoid spawning file size polling thread when not in -J mode
authorJoey Hess <joeyh@joeyh.name>
Tue, 17 Nov 2015 01:21:58 +0000 (21:21 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 17 Nov 2015 01:21:58 +0000 (21:21 -0400)
Annex/Content.hs
Messages/Progress.hs

index 90486f91287edd46633bde0206ed273d93e11010..612a96a6b1d96db86c21c4c8f7db799015427145 100644 (file)
@@ -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
index c14e7e6b132ff0680ff5e0dd40316f2b7c3f2b66..25d803b1b2732b8bf49b66e48bf8a10e2bbaed72 100644 (file)
@@ -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 ()