summaryrefslogtreecommitdiff
path: root/Messages
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-09-09 16:15:39 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-09-09 16:15:39 -0400
commitcf54d93481e965d626a9d31612756ee8b7d85b5a (patch)
tree202ba7a28a3376b22046ce25b90ae0a0673e534f /Messages
parentc5ff422786d7a25a0b2d5680d9b85b5ff27ebd46 (diff)
make --json-progress work for url downloads
Diffstat (limited to 'Messages')
-rw-r--r--Messages/Progress.hs28
1 files changed, 16 insertions, 12 deletions
diff --git a/Messages/Progress.hs b/Messages/Progress.hs
index 14aebe6c9..f21ccae0b 100644
--- a/Messages/Progress.hs
+++ b/Messages/Progress.hs
@@ -75,25 +75,29 @@ metered othermeter key a = case keySize key of
Just om -> combineMeterUpdate m om
{- Use when the command's own progress output is preferred.
- - The command's output will be suppressed and git-annex's progress output
+ - The command's output will be suppressed and git-annex's progress meter
- used for concurrent output, and json progress. -}
commandMetered :: Maybe MeterUpdate -> Key -> (MeterUpdate -> Annex a) -> Annex a
commandMetered combinemeterupdate key a =
- withMessageState $ \s -> case outputType s of
- JSONOutput True -> usemeter
- NormalOutput | concurrentOutputEnabled s -> usemeter
- _ -> a (fromMaybe nullMeterUpdate combinemeterupdate)
- where
- usemeter = metered combinemeterupdate key a
-
-{- 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 =
- withMessageState $ \s -> if concurrentOutputEnabled s
+ withMessageState $ \s -> if needOutputMeter s
+ then metered combinemeterupdate key a
+ else a (fromMaybe nullMeterUpdate combinemeterupdate)
+
+{- Poll file size to display meter, but only when concurrent output or
+ - json progress needs the information. -}
+meteredFile :: FilePath -> Maybe MeterUpdate -> Key -> Annex a -> Annex a
+meteredFile file combinemeterupdate key a =
+ withMessageState $ \s -> if needOutputMeter s
then metered combinemeterupdate key $ \p ->
watchFileSize file p a
else a
+needOutputMeter :: MessageState -> Bool
+needOutputMeter s = case outputType s of
+ JSONOutput True -> True
+ NormalOutput | concurrentOutputEnabled s -> True
+ _ -> False
+
{- Progress dots. -}
showProgressDots :: Annex ()
showProgressDots = outputMessage JSON.none "."