add missing locking of ContentIdentifier database when writing

This is not super efficient; it would be better to lock the database
once and build up a queue of changes and flush once.

But, storeExportWithContentIdentifier is likely going to be the really
expensive part, so let's do the simple thing and only optimise later if
needed.
This commit is contained in:
Joey Hess 2019-03-07 13:32:33 -04:00
parent 3f449f845e
commit 93025dd59f
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 4 additions and 4 deletions

View file

@ -19,6 +19,7 @@ import qualified Database.Export as Export
import qualified Database.ContentIdentifier as ContentIdentifier
import Annex.Export
import Annex.Import
import Annex.LockFile
import Config
import Git.Types (fromRef)
import Logs.Export
@ -155,7 +156,9 @@ adjustExportImport r = case M.lookup "exporttree" (config r) of
storeExportWithContentIdentifier (importActions r') f k loc knowncids p >>= \case
Nothing -> return False
Just newcid -> do
liftIO $ ContentIdentifier.recordContentIdentifier db (uuid r') newcid k
withExclusiveLock gitAnnexContentIdentifierLock $ do
liftIO $ ContentIdentifier.recordContentIdentifier db (uuid r') newcid k
liftIO $ ContentIdentifier.flushDbQueue db
recordContentIdentifier (uuid r') newcid k
return True
, removeExport = \k loc -> do

View file

@ -15,9 +15,6 @@ this.
Note that updating the db needs to write lock it.
* Remote.Helper.ExportImport calls recordContentIdentifier on a database
that is not write locked.
* Need to support annex-tracking-branch configuration, which documentation
says makes git-annex sync and assistant do imports.