git annex drop -- do not try to drop if key is not in backend

This commit is contained in:
Joey Hess 2010-10-17 10:47:46 -04:00
parent a0b040524a
commit 6bfa534aa4
2 changed files with 19 additions and 10 deletions

View file

@ -165,13 +165,20 @@ getCmd file = notinBackend file err $ \(key, backend) -> do
- if it's safe to do so. -} - if it's safe to do so. -}
dropCmd :: FilePath -> Annex () dropCmd :: FilePath -> Annex ()
dropCmd file = notinBackend file err $ \(key, backend) -> do dropCmd file = notinBackend file err $ \(key, backend) -> do
inbackend <- Backend.hasKey key
if (not inbackend)
then return () -- no-op
else do
force <- Annex.flagIsSet Force force <- Annex.flagIsSet Force
if (not force) if (not force)
then requireEnoughCopies key then requireEnoughCopies key
else return () else return ()
success <- Backend.removeKey backend key success <- Backend.removeKey backend key
if (success) if (success)
then do then cleanup key
else error $ "backend refused to drop " ++ file
where
cleanup key = do
logStatus key ValueMissing logStatus key ValueMissing
inannex <- inAnnex key inannex <- inAnnex key
if (inannex) if (inannex)
@ -181,8 +188,6 @@ dropCmd file = notinBackend file err $ \(key, backend) -> do
liftIO $ removeFile loc liftIO $ removeFile loc
return () return ()
else return () else return ()
else error $ "backend refused to drop " ++ file
where
err = error $ "not annexed " ++ file err = error $ "not annexed " ++ file
{- Fixes the symlink to an annexed file. -} {- Fixes the symlink to an annexed file. -}

6
TODO
View file

@ -1,7 +1,11 @@
* bug: cannot "git annex ../foo" (GitRepo.relative is buggy and * bug: cannot "git annex ../foo" (GitRepo.relative is buggy and
git-ls-files also refuses w/o --full-name, which would need other changes) git-ls-files also refuses w/o --full-name, which would need other changes)
* --push/--pull/--want * bug: git annex add file is silent if file was a symlink and got replaced
with a file. The you then git command -a, you'll check in the fil contents..
* --push/--pull should take a reponame and files, and push those files
to that repo; dropping them from the current repo
* how to handle git mv file? -> git annex fix -> run automatically? * how to handle git mv file? -> git annex fix -> run automatically?