git-annex/Command/CalcKey.hs
Joey Hess 8355dba5cc
plumb MeterUpdate into getKey
No behavior changes, but this shows everywhere that a progress meter
could be displayed when hashing a file to add to the annex.

Many of the places don't make sense to display a progress meter though,
eg when importing the copy of the file probably swamps the hashing of
the file.
2019-06-25 11:43:24 -04:00

27 lines
647 B
Haskell

{- git-annex command
-
- Copyright 2016 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
module Command.CalcKey where
import Command
import Backend (genKey)
import Types.KeySource
import Utility.Metered
cmd :: Command
cmd = noCommit $ noMessages $ dontCheck repoExists $
command "calckey" SectionPlumbing
"calulate key for a file"
(paramRepeating paramFile)
(batchable run (pure ()))
run :: () -> String -> Annex Bool
run _ file = genKey (KeySource file file Nothing) nullMeterUpdate Nothing >>= \case
Just (k, _) -> do
liftIO $ putStrLn $ serializeKey k
return True
Nothing -> return False