2010-11-02 19:04:24 -04: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 16:05:05 -04:00
|
|
|
import Content
|
2010-11-08 15:15:21 -04:00
|
|
|
import Messages
|
2010-11-02 19:04:24 -04:00
|
|
|
|
2010-12-30 15:06:26 -04:00
|
|
|
command :: [Command]
|
2011-03-19 18:58:49 -04:00
|
|
|
command = [repoCommand "dropkey" (paramRepeating paramKey) seek
|
2010-12-30 15:06:26 -04:00
|
|
|
"drops annexed content for specified keys"]
|
|
|
|
|
2010-12-30 14:19:16 -04:00
|
|
|
seek :: [CommandSeek]
|
2010-11-11 18:54:52 -04:00
|
|
|
seek = [withKeys start]
|
|
|
|
|
2011-03-15 22:42:34 -04:00
|
|
|
start :: CommandStartKey
|
|
|
|
start key = do
|
|
|
|
present <- inAnnex key
|
2011-01-26 00:17:38 -04:00
|
|
|
force <- Annex.getState Annex.force
|
2010-11-22 17:51:55 -04:00
|
|
|
if not present
|
2010-11-02 19:04:24 -04:00
|
|
|
then return Nothing
|
2010-11-22 17:51:55 -04:00
|
|
|
else if not force
|
2010-11-02 19:04:24 -04:00
|
|
|
then error "dropkey is can cause data loss; use --force if you're sure you want to do this"
|
|
|
|
else do
|
2011-03-15 22:42:34 -04:00
|
|
|
showStart "dropkey" (show key)
|
2010-11-02 19:04:24 -04:00
|
|
|
return $ Just $ perform key
|
|
|
|
|
2010-12-30 14:19:16 -04:00
|
|
|
perform :: Key -> CommandPerform
|
2010-11-02 19:04:24 -04:00
|
|
|
perform key = do
|
2010-11-08 19:26:37 -04:00
|
|
|
removeAnnex key
|
2010-11-02 19:04:24 -04:00
|
|
|
return $ Just $ cleanup key
|
|
|
|
|
2010-12-30 14:19:16 -04:00
|
|
|
cleanup :: Key -> CommandCleanup
|
2010-11-02 19:04:24 -04:00
|
|
|
cleanup key = do
|
|
|
|
logStatus key ValueMissing
|
|
|
|
return True
|
|
|
|
|