reorder associated file db update

There's a potential race where the smudge filter is run at the same time an
object is being downloaded. If the download finished after the inAnnex
check, and before the keys db was updated, the associated file would not
get updated with the downloaded content.

I'm not sure this closes the race; it may only narrow the window. Problem
is, the keys database needs to communicate between two different processes.
In the case of the assistant, the transferkeys command is the other
process, and it closes the db handle after getting the file. So, it should
re-open the database and so see the update that the smudge filter has
written to it. But, what if the smudge filter takes a while to update the
database?
This commit is contained in:
Joey Hess 2016-05-16 14:55:05 -04:00
parent 9249af66f6
commit 0860731760
Failed to extract signature

View file

@ -47,6 +47,7 @@ smudge file = do
case parseLinkOrPointer b of
Nothing -> liftIO $ B.putStr b
Just k -> do
Database.Keys.addAssociatedFile k =<< inRepo (toTopFilePath file)
-- A previous unlocked checkout of the file may have
-- led to the annex object getting modified;
-- don't provide such modified content as it
@ -61,7 +62,6 @@ smudge file = do
=<< catchMaybeIO (B.readFile content)
, liftIO $ B.putStr b
)
Database.Keys.addAssociatedFile k =<< inRepo (toTopFilePath file)
stop
-- Clean filter is fed file content on stdin, decides if a file