2010-11-02 23:04:24 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2010 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.DropKey where
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import qualified Annex
|
|
|
|
import LocationLog
|
|
|
|
import Types
|
2011-01-16 20:05:05 +00:00
|
|
|
import Content
|
2010-11-08 19:15:21 +00:00
|
|
|
import Messages
|
2010-11-02 23:04:24 +00:00
|
|
|
|
2010-12-30 19:06:26 +00:00
|
|
|
command :: [Command]
|
2011-03-19 22:58:49 +00:00
|
|
|
command = [repoCommand "dropkey" (paramRepeating paramKey) seek
|
2010-12-30 19:06:26 +00:00
|
|
|
"drops annexed content for specified keys"]
|
|
|
|
|
2010-12-30 18:19:16 +00:00
|
|
|
seek :: [CommandSeek]
|
2010-11-11 22:54:52 +00:00
|
|
|
seek = [withKeys start]
|
|
|
|
|
2011-03-16 02:42:34 +00:00
|
|
|
start :: CommandStartKey
|
|
|
|
start key = do
|
|
|
|
present <- inAnnex key
|
2011-01-26 04:17:38 +00:00
|
|
|
force <- Annex.getState Annex.force
|
2010-11-22 21:51:55 +00:00
|
|
|
if not present
|
2010-11-02 23:04:24 +00:00
|
|
|
then return Nothing
|
2010-11-22 21:51:55 +00:00
|
|
|
else if not force
|
2010-11-02 23:04:24 +00:00
|
|
|
then error "dropkey is can cause data loss; use --force if you're sure you want to do this"
|
|
|
|
else do
|
2011-03-16 02:42:34 +00:00
|
|
|
showStart "dropkey" (show key)
|
2010-11-02 23:04:24 +00:00
|
|
|
return $ Just $ perform key
|
|
|
|
|
2010-12-30 18:19:16 +00:00
|
|
|
perform :: Key -> CommandPerform
|
2010-11-02 23:04:24 +00:00
|
|
|
perform key = do
|
2010-11-08 23:26:37 +00:00
|
|
|
removeAnnex key
|
2010-11-02 23:04:24 +00:00
|
|
|
return $ Just $ cleanup key
|
|
|
|
|
2010-12-30 18:19:16 +00:00
|
|
|
cleanup :: Key -> CommandCleanup
|
2010-11-02 23:04:24 +00:00
|
|
|
cleanup key = do
|
|
|
|
logStatus key ValueMissing
|
|
|
|
return True
|
|
|
|
|