This commit is contained in:
Joey Hess 2019-03-04 18:20:12 -04:00
parent bc509143e5
commit 554b7b7f3e
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 9 additions and 5 deletions

View file

@ -23,6 +23,7 @@ import Annex.LockFile
import Config import Config
import Git.Types (fromRef) import Git.Types (fromRef)
import Logs.Export import Logs.Export
import Logs.ContentIdentifier (recordContentIdentifier)
import qualified Data.Map as M import qualified Data.Map as M
import Control.Concurrent.STM import Control.Concurrent.STM
@ -132,9 +133,9 @@ adjustExportImport r = case M.lookup "exporttree" (config r) of
lcklckv <- liftIO newEmptyTMVarIO lcklckv <- liftIO newEmptyTMVarIO
dbtv <- liftIO newEmptyTMVarIO dbtv <- liftIO newEmptyTMVarIO
let store f k loc p = do let store f k loc p = do
-- Only open the database once it's needed, since -- Only open the database once it's needed,
-- we have to take an exclusive write lock. -- and take an exclusive write lock.
-- The write lock will remain held while the -- The write lock will then remain held while the
-- process is running. -- process is running.
db <- liftIO (atomically (tryReadTMVar dbtv)) >>= \case db <- liftIO (atomically (tryReadTMVar dbtv)) >>= \case
Just (db, _lck) -> return db Just (db, _lck) -> return db
@ -159,7 +160,7 @@ adjustExportImport r = case M.lookup "exporttree" (config r) of
Nothing -> return False Nothing -> return False
Just newcid -> do Just newcid -> do
liftIO $ ContentIdentifier.recordContentIdentifier db (uuid r') newcid k liftIO $ ContentIdentifier.recordContentIdentifier db (uuid r') newcid k
-- TODO update git-annex branch recordContentIdentifier (uuid r') newcid k
return True return True
return $ r' return $ r'

View file

@ -13,7 +13,10 @@ this.
* Should the ContentIdentifier db be multiwriter? It would simplify * Should the ContentIdentifier db be multiwriter? It would simplify
the situation with the long-lived lock of it in adjustExportImport the situation with the long-lived lock of it in adjustExportImport
* fix TODO in adjustExportImport OTOH, if a single process, such as the assistant, exported one tree,
and then another, multiwriter would mean no guarantee that reading
from the contentidentifier database would see values that were earlier
written by the same process.
* Test export to importtree=yes remote and make sure it uses * Test export to importtree=yes remote and make sure it uses
storeExportWithContentIdentifier correctly. storeExportWithContentIdentifier correctly.