From: Joey Hess Date: Tue, 22 Dec 2020 16:00:11 +0000 (-0400) Subject: improve storage of redundant ContentIdentifiers X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~98^2~299^2~10 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=06ef1b7d68ee2b149e663f2362e5685303d0bd3a;p=git-annex.git improve storage of redundant ContentIdentifiers When a ContentIdentifier is already recorded, don't add it to the log again, and avoid updating the log. --- diff --git a/Logs/ContentIdentifier.hs b/Logs/ContentIdentifier.hs index 38f904ae2b..16c3969155 100644 --- a/Logs/ContentIdentifier.hs +++ b/Logs/ContentIdentifier.hs @@ -32,12 +32,16 @@ recordContentIdentifier :: RemoteStateHandle -> ContentIdentifier -> Key -> Anne recordContentIdentifier (RemoteStateHandle u) cid k = do c <- liftIO currentVectorClock config <- Annex.getGitConfig - Annex.Branch.change (remoteContentIdentifierLogFile config k) $ - buildLog . addcid c . parseLog + Annex.Branch.maybeChange (remoteContentIdentifierLogFile config k) $ + addcid c . parseLog 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 - m = simpleMap l + m = simpleMap v + l = contentIdentifierList (M.lookup u m) -- | Get all known content identifiers for a key. getContentIdentifiers :: Key -> Annex [(RemoteStateHandle, [ContentIdentifier])]