summaryrefslogtreecommitdiff
path: root/Command/Drop.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-10-09 15:48:02 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-10-09 15:48:02 -0400
commit3c43af79d56a25bfff3eae1c1342c9a308223347 (patch)
treee52a095b8963ca42d6530d40bee5858ea8bfcf3c /Command/Drop.hs
parente36bfabb0e56087771d385a9f4ecdb342f1f14db (diff)
fix local dropping to not require extra locking of copies, but only that the local copy be locked for removal
Diffstat (limited to 'Command/Drop.hs')
-rw-r--r--Command/Drop.hs16
1 files changed, 7 insertions, 9 deletions
diff --git a/Command/Drop.hs b/Command/Drop.hs
index a2bca2204..d14cdad18 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -91,15 +91,11 @@ startRemote afile numcopies key remote = do
showStart' ("drop " ++ Remote.name remote) key afile
next $ performRemote key afile numcopies remote
--- Note that lockContentExclusive is called before checking if the key is
--- present on enough remotes to allow removal. This avoids a scenario where two
--- or more remotes are trying to remove a key at the same time, and each
--- sees the key is present on the other.
performLocal :: Key -> AssociatedFile -> NumCopies -> [VerifiedCopy] -> CommandPerform
-performLocal key afile numcopies preverified = lockContentExclusive key $ \contentlock -> do
+performLocal key afile numcopies preverified = lockContentForRemoval key $ \contentlock -> do
u <- getUUID
(tocheck, verified) <- verifiableCopies key [u]
- doDrop u key afile numcopies [] (preverified ++ verified) tocheck
+ doDrop u (Just contentlock) key afile numcopies [] (preverified ++ verified) tocheck
( \proof -> do
liftIO $ debugM "drop" $ unwords
[ "Dropping from here"
@@ -121,7 +117,7 @@ performRemote key afile numcopies remote = do
-- When the local repo has the key, that's one additional copy,
-- as long as the local repo is not untrusted.
(tocheck, verified) <- verifiableCopies key [uuid]
- doDrop uuid key afile numcopies [uuid] verified tocheck
+ doDrop uuid Nothing key afile numcopies [uuid] verified tocheck
( \proof -> do
liftIO $ debugM "drop" $ unwords
[ "Dropping from remote"
@@ -159,6 +155,7 @@ cleanupRemote key remote ok = do
-}
doDrop
:: UUID
+ -> Maybe ContentRemovalLock
-> Key
-> AssociatedFile
-> NumCopies
@@ -167,11 +164,12 @@ doDrop
-> [UnVerifiedCopy]
-> (Maybe SafeDropProof -> CommandPerform, CommandPerform)
-> CommandPerform
-doDrop dropfrom key afile numcopies skip preverified check (dropaction, nodropaction) =
+doDrop dropfrom contentlock key afile numcopies skip preverified check (dropaction, nodropaction) =
ifM (Annex.getState Annex.force)
( dropaction Nothing
, ifM (checkRequiredContent dropfrom key afile)
- ( verifyEnoughCopiesToDrop nolocmsg key numcopies
+ ( verifyEnoughCopiesToDrop nolocmsg key
+ contentlock numcopies
skip preverified check
(dropaction . Just)
(forcehint nodropaction)