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
c30fd24d91, 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.
This commit is contained in:
Joey Hess 2020-07-25 11:54:34 -04:00
parent c30fd24d91
commit 2a45b5ae9a
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
11 changed files with 65 additions and 40 deletions

View file

@ -76,7 +76,7 @@ expireUnused duration = do
forM_ oldkeys $ \k -> do
debug ["removing old unused key", serializeKey k]
liftAnnex $ tryNonAsync $ do
lockContentForRemoval k removeAnnex
lockContentForRemoval k noop removeAnnex
logStatus k InfoMissing
where
boundry = durationToPOSIXTime <$> duration

View file

@ -99,7 +99,7 @@ startDistributionDownload d = go =<< liftIO . newVersionLocation d =<< liftIO ol
, transferKeyData = fromKey id k
}
cleanup = liftAnnex $ do
lockContentForRemoval k removeAnnex
lockContentForRemoval k noop removeAnnex
setUrlMissing k u
logStatus k InfoMissing