summaryrefslogtreecommitdiff
path: root/Commands.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-14 14:14:19 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-14 14:14:19 -0400
commita200761e66f01a271c90ce67482105befca6ef09 (patch)
tree5b2d94670d63db3201851785b3c13bf6392b251b /Commands.hs
parentf9557d7c5e2aa7ef19a5d589594154a21c7f2caa (diff)
implemented basic --drop
Diffstat (limited to 'Commands.hs')
-rw-r--r--Commands.hs24
1 files changed, 20 insertions, 4 deletions
diff --git a/Commands.hs b/Commands.hs
index b4f57d6fe..65f6f6efd 100644
--- a/Commands.hs
+++ b/Commands.hs
@@ -40,7 +40,7 @@ defaultCmd file = do
addCmd :: FilePath -> Annex ()
addCmd file = inBackend file err $ do
liftIO $ checkLegal file
- stored <- Backend.storeFile file
+ stored <- Backend.storeFileKey file
g <- Annex.gitRepo
case (stored) of
Nothing -> error $ "no backend could store: " ++ file
@@ -76,7 +76,7 @@ addCmd file = inBackend file err $ do
{- Inverse of addCmd. -}
unannexCmd :: FilePath -> Annex ()
unannexCmd file = notinBackend file err $ \(key, backend) -> do
- Backend.dropFile backend key
+ Backend.removeKey backend key
logStatus key ValueMissing
g <- Annex.gitRepo
let src = annexLocation g backend key
@@ -104,7 +104,7 @@ getCmd file = notinBackend file err $ \(key, backend) -> do
g <- Annex.gitRepo
let dest = annexLocation g backend key
liftIO $ createDirectoryIfMissing True (parentDir dest)
- success <- Backend.retrieveFile backend key dest
+ success <- Backend.retrieveKeyFile backend key dest
if (success)
then do
logStatus key ValuePresent
@@ -119,7 +119,23 @@ wantCmd file = do error "not implemented" -- TODO
{- Indicates a file is not wanted. -}
dropCmd :: FilePath -> Annex ()
-dropCmd file = do error "not implemented" -- TODO
+dropCmd file = notinBackend file err $ \(key, backend) -> do
+ -- TODO only remove if enough copies are present elsewhere
+ success <- Backend.removeKey backend key
+ if (success)
+ then do
+ logStatus key ValueMissing
+ inannex <- inAnnex backend key
+ if (inannex)
+ then do
+ g <- Annex.gitRepo
+ let loc = annexLocation g backend key
+ liftIO $ removeFile loc
+ return ()
+ else return ()
+ else error $ "backend refused to drop " ++ file
+ where
+ err = error $ "not annexed " ++ file
{- Pushes all files to a remote repository. -}
pushCmd :: String -> Annex ()