summaryrefslogtreecommitdiff
path: root/Command/Move.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-08-20 20:08:45 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-08-20 20:13:47 -0400
commit28ac29b518a49363788b3607130cee5aff5534e9 (patch)
tree25985e4f7937c64e662ef5447651f4e44d2b9cbf /Command/Move.hs
parent6f8f6b7dde108168ac5a9f0b3fb2cb8ea2d2f60c (diff)
use types to enforce that removeAnnex can only be called inside lockContent
This fixed one bug where it needed to be and wasn't (in Assistant.Unused). And also found one place where lockContent was used unnecessarily (by drop --from remote). A few other places like uninit probably don't really need to lockContent, but it doesn't hurt to do call it anyway. This commit was sponsored by David Wagner.
Diffstat (limited to 'Command/Move.hs')
-rw-r--r--Command/Move.hs13
1 files changed, 3 insertions, 10 deletions
diff --git a/Command/Move.hs b/Command/Move.hs
index f70608a6f..c3d641edd 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -91,7 +91,7 @@ expectedPresent dest key = do
return $ dest `elem` remotes
toPerform :: Remote -> Bool -> Key -> AssociatedFile -> Bool -> Either String Bool -> CommandPerform
-toPerform dest move key afile fastcheck isthere = moveLock move key $
+toPerform dest move key afile fastcheck isthere = do
case isthere of
Left err -> do
showNote err
@@ -115,8 +115,8 @@ toPerform dest move key afile fastcheck isthere = moveLock move key $
finish
where
finish
- | move = do
- removeAnnex key
+ | move = lockContent key $ \contentlock -> do
+ removeAnnex contentlock
next $ Command.Drop.cleanupLocal key
| otherwise = next $ return True
@@ -164,10 +164,3 @@ fromPerform src move key afile = ifM (inAnnex key)
dispatch True True = do -- finish moving
ok <- Remote.removeKey src key
next $ Command.Drop.cleanupRemote key src ok
-
-{- Locks a key in order for it to be moved away from the current repository.
- - No lock is needed when a key is being copied, or moved to the current
- - repository. -}
-moveLock :: Bool -> Key -> Annex a -> Annex a
-moveLock True key a = lockContent key a
-moveLock False _ a = a