summaryrefslogtreecommitdiff
path: root/P2P
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2020-07-25 11:54:34 -0400
committerJoey Hess <joeyh@joeyh.name>2020-07-25 11:59:33 -0400
commit2a45b5ae9a8af00683307a8d77d7508c76dd39c7 (patch)
treeaf1b4a9b0dc2ceada0b84bcb7746cffba784f2e0 /P2P
parentc30fd24d91d1217b7b764953dd3ded6b54d78b2e (diff)
avoid failure to lock content of removed file causing drop etc to fail
This was already prevented in other ways, but as seen in commit c30fd24d91d1217b7b764953dd3ded6b54d78b2e, those were a bit fragile. And I'm not sure races were avoided in every case before. At least a race between two separate git-annex processes, dropping the same content, seemed possible. This way, if locking fails, and the content is not present, it will always do the right thing. Also, it avoids the overhead of an unncessary inAnnex check for every file. This commit was sponsored by Denis Dzyubenko on Patreon.
Diffstat (limited to 'P2P')
-rw-r--r--P2P/Annex.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/P2P/Annex.hs b/P2P/Annex.hs
index ec0896dd29..9f089aa9d8 100644
--- a/P2P/Annex.hs
+++ b/P2P/Annex.hs
@@ -107,12 +107,14 @@ runLocal runst runner a = case a of
Left e -> return $ Left $ ProtoFailureException e
Right result -> runner (next result)
RemoveContent k next -> do
+ let cleanup = do
+ logStatus k InfoMissing
+ return True
v <- tryNonAsync $
ifM (Annex.Content.inAnnex k)
- ( lockContentForRemoval k $ \contentlock -> do
+ ( lockContentForRemoval k cleanup $ \contentlock -> do
removeAnnex contentlock
- logStatus k InfoMissing
- return True
+ cleanup
, return True
)
case v of