assistant: Fix race in v6 mode that caused downloaded file content to sometimes not replace pointer files.

The keys database handle needs to be closed after merging, because the
smudge filter, in another process, updates the database. Old cached info
can be read for a while from the open database handle; closing it ensures
that the info written by the smudge filter is available.

This is pretty horribly ad-hoc, and it's especially nasty that the
transferrer closes the database every time.
This commit is contained in:
Joey Hess 2016-05-16 14:49:12 -04:00
parent fb8ab2469d
commit 5f0b551c0c
Failed to extract signature
5 changed files with 38 additions and 4 deletions

View file

@ -16,6 +16,7 @@ import Annex.Transfer
import qualified Remote
import Utility.SimpleProtocol (dupIoHandles)
import Git.Types (RemoteName)
import qualified Database.Keys
data TransferRequest = TransferRequest Direction Remote Key AssociatedFile
@ -41,8 +42,13 @@ start = do
return ok
| otherwise = notifyTransfer direction file $
download (Remote.uuid remote) key file forwardRetry observer $ \p ->
getViaTmp (RemoteVerify remote) key $ \t ->
Remote.retrieveKeyFile remote key file t p
getViaTmp (RemoteVerify remote) key $ \t -> do
r <- Remote.retrieveKeyFile remote key file t p
-- Make sure we get the current
-- associated files data for the key,
-- not old cached data.
Database.Keys.closeDb
return r
observer False t tinfo = recordFailedTransfer t tinfo
observer True _ _ = noop