dead --key: Can be used to mark a key as dead.
This commit is contained in:
parent
6eefc5db65
commit
f8ab3bc449
6 changed files with 79 additions and 20 deletions
|
@ -1,6 +1,6 @@
|
|||
{- git-annex command
|
||||
-
|
||||
- Copyright 2011 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2011, 2015 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
@ -8,12 +8,37 @@
|
|||
module Command.Dead where
|
||||
|
||||
import Command
|
||||
import Common.Annex
|
||||
import qualified Annex
|
||||
import Types.TrustLevel
|
||||
import Types.Key
|
||||
import Command.Trust (trustCommand)
|
||||
import Logs.Location
|
||||
import Remote (keyLocations)
|
||||
|
||||
cmd :: [Command]
|
||||
cmd = [command "dead" (paramRepeating paramRemote) seek
|
||||
SectionSetup "hide a lost repository"]
|
||||
cmd = [withOptions [keyOption] $
|
||||
command "dead" (paramRepeating paramRemote) seek
|
||||
SectionSetup "hide a lost repository or key"]
|
||||
|
||||
seek :: CommandSeek
|
||||
seek = trustCommand "dead" DeadTrusted
|
||||
seek ps = maybe (trustCommand "dead" DeadTrusted ps) (flip seekKey ps)
|
||||
=<< Annex.getField "key"
|
||||
|
||||
seekKey :: String -> CommandSeek
|
||||
seekKey ks = case file2key ks of
|
||||
Nothing -> error "Invalid key"
|
||||
Just key -> withNothing (startKey key)
|
||||
|
||||
startKey :: Key -> CommandStart
|
||||
startKey key = do
|
||||
showStart "dead" (key2file key)
|
||||
ls <- keyLocations key
|
||||
case ls of
|
||||
[] -> next $ performKey key
|
||||
_ -> error "This key is still known to be present in some locations; not marking as dead."
|
||||
|
||||
performKey :: Key -> CommandPerform
|
||||
performKey key = do
|
||||
setDead key
|
||||
next $ return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue