aboutsummaryrefslogtreecommitdiff
path: root/Command/ReadPresentKey.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-03-20 11:22:27 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-03-20 11:22:27 -0400
commit82ee689db44ebabca2ecd093f9da40ef46fbc067 (patch)
tree74985d178621fabcc3d450c15054397afec9b84d /Command/ReadPresentKey.hs
parent6c43dd47ff2f1b8e21480b3b4b1a131ef283444b (diff)
readpresentkey: New plumbing command for checking location log.
Diffstat (limited to 'Command/ReadPresentKey.hs')
-rw-r--r--Command/ReadPresentKey.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/Command/ReadPresentKey.hs b/Command/ReadPresentKey.hs
new file mode 100644
index 000000000..8125ddf7e
--- /dev/null
+++ b/Command/ReadPresentKey.hs
@@ -0,0 +1,30 @@
+{- git-annex command
+ -
+ - Copyright 2015 Joey Hess <id@joeyh.name>
+ -
+ - 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"