readpresentkey: New plumbing command for checking location log.
This commit is contained in:
parent
101302f7fc
commit
50ef4105e3
4 changed files with 47 additions and 1 deletions
30
Command/ReadPresentKey.hs
Normal file
30
Command/ReadPresentKey.hs
Normal file
|
@ -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"
|
Loading…
Add table
Add a link
Reference in a new issue