From 50ef4105e3265f2f49cc308aa380d58f7a73f1ff Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 20 Mar 2015 11:22:27 -0400 Subject: [PATCH] readpresentkey: New plumbing command for checking location log. --- CmdLine/GitAnnex.hs | 2 ++ Command/ReadPresentKey.hs | 30 ++++++++++++++++++++++++++++++ debian/changelog | 6 ++++++ doc/git-annex.mdwn | 10 +++++++++- 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 Command/ReadPresentKey.hs diff --git a/CmdLine/GitAnnex.hs b/CmdLine/GitAnnex.hs index f25af34b36..f2953da362 100644 --- a/CmdLine/GitAnnex.hs +++ b/CmdLine/GitAnnex.hs @@ -29,6 +29,7 @@ import qualified Command.DropKey import qualified Command.TransferKey import qualified Command.TransferKeys import qualified Command.SetPresentKey +import qualified Command.ReadPresentKey import qualified Command.ReKey import qualified Command.MetaData import qualified Command.View @@ -156,6 +157,7 @@ cmds = concat , Command.TransferKey.cmd , Command.TransferKeys.cmd , Command.SetPresentKey.cmd + , Command.ReadPresentKey.cmd , Command.ReKey.cmd , Command.MetaData.cmd , Command.View.cmd diff --git a/Command/ReadPresentKey.hs b/Command/ReadPresentKey.hs new file mode 100644 index 0000000000..8125ddf7e2 --- /dev/null +++ b/Command/ReadPresentKey.hs @@ -0,0 +1,30 @@ +{- git-annex command + - + - Copyright 2015 Joey Hess + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Command.ReadPresentKey where + +import Common.Annex +import Command +import Logs.Location +import Types.Key + +cmd :: [Command] +cmd = [noCommit $ command "readpresentkey" (paramPair paramKey paramUUID) seek + SectionPlumbing "read records of where key is present"] + +seek :: CommandSeek +seek = withWords start + +start :: [String] -> CommandStart +start (ks:us:[]) = do + ls <- loggedLocations k + if toUUID us `elem` ls + then liftIO exitSuccess + else liftIO exitFailure + where + k = fromMaybe (error "bad key") (file2key ks) +start _ = error "Wrong number of parameters" diff --git a/debian/changelog b/debian/changelog index 80df2ca721..d3c3b048ac 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +git-annex (5.20150318) UNRELEASED; urgency=medium + + * readpresentkey: New plumbing command for checking location log. + + -- Joey Hess Thu, 19 Mar 2015 17:05:32 -0400 + git-annex (5.20150317) unstable; urgency=medium * fsck: Incremental fsck uses sqlite to store its records, instead diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index c33633e033..c0bf08e0ba 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -1000,7 +1000,15 @@ subdirectories). * `setpresentkey key uuid [1|0]` This plumbing-level command changes git-annex's records about whether - the specified key is present in a remote with the specified uuid. + the specified key's content is present in a remote with the specified uuid. + +* `readpresentkey key uuid` + + This plumbing-level command reads git-annex's records about whether + the specified key's content is present in the remote with the speficied + uuid. + + It exits 0 if the key is recorded to be present and 1 if not. * `rekey [file key ...]`