diff options
author | Joey Hess <joey@kitenet.net> | 2010-11-02 19:04:24 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-11-02 19:04:24 -0400 |
commit | 0eae5b806c76b0fa3e21fbae6e5f2d9a39a04cce (patch) | |
tree | 53aada39ec10bc6217507bce1a9add3b86b3793b /Command/Drop.hs | |
parent | 606ed6bb3566fa86c1783e3f1c7d799a6f1be8d1 (diff) |
broke subcommands out into separate modules
Diffstat (limited to 'Command/Drop.hs')
-rw-r--r-- | Command/Drop.hs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Command/Drop.hs b/Command/Drop.hs new file mode 100644 index 000000000..6cdf216f4 --- /dev/null +++ b/Command/Drop.hs @@ -0,0 +1,50 @@ +{- git-annex command + - + - Copyright 2010 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Command.Drop where + +import Control.Monad.State (liftIO) +import System.Directory + +import Command +import qualified Annex +import Locations +import qualified Backend +import LocationLog +import Types +import Core + +{- Indicates a file's content is not wanted anymore, and should be removed + - if it's safe to do so. -} +start :: SubCmdStartString +start file = isAnnexed file $ \(key, backend) -> do + inbackend <- Backend.hasKey key + if (not inbackend) + then return Nothing + else do + showStart "drop" file + return $ Just $ perform key backend + +perform :: Key -> Backend -> SubCmdPerform +perform key backend = do + success <- Backend.removeKey backend key + if (success) + then return $ Just $ cleanup key + else return Nothing + +cleanup :: Key -> SubCmdCleanup +cleanup key = do + logStatus key ValueMissing + inannex <- inAnnex key + if (inannex) + then do + g <- Annex.gitRepo + let loc = annexLocation g key + liftIO $ removeFile loc + return True + else return True + |