summaryrefslogtreecommitdiff
path: root/Commands.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-17 10:47:46 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-17 10:47:46 -0400
commit6bfa534aa4d7552c4ccfdb9523b55da19fac8883 (patch)
tree7d9f9789ddb99bc04289c276f098b1803d752f99 /Commands.hs
parenta0b040524a595c16ddb2dbead205ca8ccb6890aa (diff)
git annex drop -- do not try to drop if key is not in backend
Diffstat (limited to 'Commands.hs')
-rw-r--r--Commands.hs23
1 files changed, 14 insertions, 9 deletions
diff --git a/Commands.hs b/Commands.hs
index 5931bf0a9..b446dbfac 100644
--- a/Commands.hs
+++ b/Commands.hs
@@ -165,13 +165,20 @@ getCmd file = notinBackend file err $ \(key, backend) -> do
- if it's safe to do so. -}
dropCmd :: FilePath -> Annex ()
dropCmd file = notinBackend file err $ \(key, backend) -> do
- force <- Annex.flagIsSet Force
- if (not force)
- then requireEnoughCopies key
- else return ()
- success <- Backend.removeKey backend key
- if (success)
- then do
+ inbackend <- Backend.hasKey key
+ if (not inbackend)
+ then return () -- no-op
+ else do
+ force <- Annex.flagIsSet Force
+ if (not force)
+ then requireEnoughCopies key
+ else return ()
+ success <- Backend.removeKey backend key
+ if (success)
+ then cleanup key
+ else error $ "backend refused to drop " ++ file
+ where
+ cleanup key = do
logStatus key ValueMissing
inannex <- inAnnex key
if (inannex)
@@ -181,8 +188,6 @@ dropCmd file = notinBackend file err $ \(key, backend) -> do
liftIO $ removeFile loc
return ()
else return ()
- else error $ "backend refused to drop " ++ file
- where
err = error $ "not annexed " ++ file
{- Fixes the symlink to an annexed file. -}