improve storage of redundant ContentIdentifiers
When a ContentIdentifier is already recorded, don't add it to the log again, and avoid updating the log.
This commit is contained in:
parent
7f7094a7cb
commit
06ef1b7d68
1 changed files with 8 additions and 4 deletions
|
@ -32,12 +32,16 @@ recordContentIdentifier :: RemoteStateHandle -> ContentIdentifier -> Key -> Anne
|
||||||
recordContentIdentifier (RemoteStateHandle u) cid k = do
|
recordContentIdentifier (RemoteStateHandle u) cid k = do
|
||||||
c <- liftIO currentVectorClock
|
c <- liftIO currentVectorClock
|
||||||
config <- Annex.getGitConfig
|
config <- Annex.getGitConfig
|
||||||
Annex.Branch.change (remoteContentIdentifierLogFile config k) $
|
Annex.Branch.maybeChange (remoteContentIdentifierLogFile config k) $
|
||||||
buildLog . addcid c . parseLog
|
addcid c . parseLog
|
||||||
where
|
where
|
||||||
addcid c l = changeMapLog c u (cid :| contentIdentifierList (M.lookup u m)) l
|
addcid c v
|
||||||
|
| cid `elem` l = Nothing -- no change needed
|
||||||
|
| otherwise = Just $ buildLog $
|
||||||
|
changeMapLog c u (cid :| l) v
|
||||||
where
|
where
|
||||||
m = simpleMap l
|
m = simpleMap v
|
||||||
|
l = contentIdentifierList (M.lookup u m)
|
||||||
|
|
||||||
-- | Get all known content identifiers for a key.
|
-- | Get all known content identifiers for a key.
|
||||||
getContentIdentifiers :: Key -> Annex [(RemoteStateHandle, [ContentIdentifier])]
|
getContentIdentifiers :: Key -> Annex [(RemoteStateHandle, [ContentIdentifier])]
|
||||||
|
|
Loading…
Add table
Reference in a new issue