2016-04-20 17:49:42 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2016 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2016-04-20 17:49:42 +00:00
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.CalcKey where
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import Backend (genKey)
|
|
|
|
import Types.KeySource
|
2019-06-25 15:37:52 +00:00
|
|
|
import Utility.Metered
|
2016-04-20 17:49:42 +00:00
|
|
|
|
|
|
|
cmd :: Command
|
|
|
|
cmd = noCommit $ noMessages $ dontCheck repoExists $
|
|
|
|
command "calckey" SectionPlumbing
|
2019-01-16 18:16:10 +00:00
|
|
|
"calulate key for a file"
|
2016-04-20 17:49:42 +00:00
|
|
|
(paramRepeating paramFile)
|
|
|
|
(batchable run (pure ()))
|
|
|
|
|
2020-09-14 20:49:33 +00:00
|
|
|
run :: () -> SeekInput -> String -> Annex Bool
|
|
|
|
run _ _ file = tryNonAsync (genKey ks nullMeterUpdate Nothing) >>= \case
|
2020-05-15 16:51:09 +00:00
|
|
|
Right (k, _) -> do
|
2019-01-14 17:03:35 +00:00
|
|
|
liftIO $ putStrLn $ serializeKey k
|
2017-12-05 19:00:50 +00:00
|
|
|
return True
|
2020-05-15 16:51:09 +00:00
|
|
|
Left _err -> return False
|
2020-02-21 13:34:59 +00:00
|
|
|
where
|
|
|
|
ks = KeySource file' file' Nothing
|
|
|
|
file' = toRawFilePath file
|