summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-10-08 14:27:37 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-10-08 14:29:35 -0400
commitbab88f3596c570346a3d069af9e3c8ed92e473c9 (patch)
tree32384db58de249ef11c524446d1e0bf757c5fa10 /Command
parent5434414bff35367aa62a4aaab0c4731a38dbe76e (diff)
add lockContentShared
Also, rename lockContent to lockContentExclusive inAnnexSafe should perhaps be eliminated, and instead use `lockContentShared inAnnex`. However, I'm waiting on that, as there are only 2 call sites for inAnnexSafe and it's fiddly.
Diffstat (limited to 'Command')
-rw-r--r--Command/Drop.hs6
-rw-r--r--Command/DropKey.hs2
-rw-r--r--Command/Move.hs2
-rw-r--r--Command/TestRemote.hs10
-rw-r--r--Command/Uninit.hs2
5 files changed, 11 insertions, 11 deletions
diff --git a/Command/Drop.hs b/Command/Drop.hs
index b23f81758..6bbdb58fd 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -88,12 +88,12 @@ startRemote afile numcopies key remote = do
showStart' ("drop " ++ Remote.name remote) key afile
next $ performRemote key afile numcopies remote
--- Note that lockContent is called before checking if the key is present
--- on enough remotes to allow removal. This avoids a scenario where two
+-- 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
-- see the key is present on the other.
performLocal :: Key -> AssociatedFile -> NumCopies -> Maybe Remote -> CommandPerform
-performLocal key afile numcopies knownpresentremote = lockContent key $ \contentlock -> do
+performLocal key afile numcopies knownpresentremote = lockContentExclusive key $ \contentlock -> do
(remotes, trusteduuids) <- Remote.keyPossibilitiesTrusted key
let trusteduuids' = case knownpresentremote of
Nothing -> trusteduuids
diff --git a/Command/DropKey.hs b/Command/DropKey.hs
index 5d44f0fcd..cdb19cabb 100644
--- a/Command/DropKey.hs
+++ b/Command/DropKey.hs
@@ -31,7 +31,7 @@ start key = stopUnless (inAnnex key) $ do
next $ perform key
perform :: Key -> CommandPerform
-perform key = lockContent key $ \contentlock -> do
+perform key = lockContentExclusive key $ \contentlock -> do
removeAnnex contentlock
next $ cleanup key
diff --git a/Command/Move.hs b/Command/Move.hs
index a83ea04dd..072c00663 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -123,7 +123,7 @@ toPerform dest move key afile fastcheck isthere =
finish
where
finish
- | move = lockContent key $ \contentlock -> do
+ | move = lockContentExclusive key $ \contentlock -> do
removeAnnex contentlock
next $ Command.Drop.cleanupLocal key
| otherwise = next $ return True
diff --git a/Command/TestRemote.hs b/Command/TestRemote.hs
index 7ee5f1359..3a44a1bde 100644
--- a/Command/TestRemote.hs
+++ b/Command/TestRemote.hs
@@ -120,7 +120,7 @@ test st r k =
, check "storeKey when already present" store
, present True
, check "retrieveKeyFile" $ do
- lockContent k removeAnnex
+ lockContentExclusive k removeAnnex
get
, check "fsck downloaded object" fsck
, check "retrieveKeyFile resume from 33%" $ do
@@ -130,20 +130,20 @@ test st r k =
sz <- hFileSize h
L.hGet h $ fromInteger $ sz `div` 3
liftIO $ L.writeFile tmp partial
- lockContent k removeAnnex
+ lockContentExclusive k removeAnnex
get
, check "fsck downloaded object" fsck
, check "retrieveKeyFile resume from 0" $ do
tmp <- prepTmp k
liftIO $ writeFile tmp ""
- lockContent k removeAnnex
+ lockContentExclusive k removeAnnex
get
, check "fsck downloaded object" fsck
, check "retrieveKeyFile resume from end" $ do
loc <- Annex.calcRepo (gitAnnexLocation k)
tmp <- prepTmp k
void $ liftIO $ copyFileExternal CopyAllMetaData loc tmp
- lockContent k removeAnnex
+ lockContentExclusive k removeAnnex
get
, check "fsck downloaded object" fsck
, check "removeKey when present" remove
@@ -189,7 +189,7 @@ testUnavailable st r k =
cleanup :: [Remote] -> [Key] -> Bool -> CommandCleanup
cleanup rs ks ok = do
forM_ rs $ \r -> forM_ ks (Remote.removeKey r)
- forM_ ks $ \k -> lockContent k removeAnnex
+ forM_ ks $ \k -> lockContentExclusive k removeAnnex
return ok
chunkSizes :: Int -> Bool -> [Int]
diff --git a/Command/Uninit.hs b/Command/Uninit.hs
index c49cc4ba0..38e062002 100644
--- a/Command/Uninit.hs
+++ b/Command/Uninit.hs
@@ -105,7 +105,7 @@ removeUnannexed = go []
go c [] = return c
go c (k:ks) = ifM (inAnnexCheck k $ liftIO . enoughlinks)
( do
- lockContent k removeAnnex
+ lockContentExclusive k removeAnnex
go c ks
, go (k:c) ks
)