From 2b414feaf2d20452794d0cdd608c6dd91feb1ec1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 24 Jul 2014 16:23:36 -0400 Subject: implement chunk logs Slightly tricky as they are not normal UUIDBased logs, but are instead maps from (uuid, chunksize) to chunkcount. This commit was sponsored by Frank Thomas. --- Annex/Branch/Transitions.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'Annex/Branch') diff --git a/Annex/Branch/Transitions.hs b/Annex/Branch/Transitions.hs index 5c2c14548..4c39f198f 100644 --- a/Annex/Branch/Transitions.hs +++ b/Annex/Branch/Transitions.hs @@ -12,8 +12,9 @@ module Annex.Branch.Transitions ( import Logs import Logs.Transitions -import Logs.UUIDBased as UUIDBased -import Logs.Presence.Pure as Presence +import qualified Logs.UUIDBased as UUIDBased +import qualified Logs.Presence.Pure as Presence +import qualified Logs.Chunk.Pure as Chunk import Types.TrustLevel import Types.UUID @@ -37,9 +38,11 @@ dropDead f content trustmap = case getLogVariety f of -- because git remotes may still exist, and they need -- to still know it's dead. | f == trustLog -> PreserveFile - | otherwise -> ChangeFile $ UUIDBased.showLog id $ dropDeadFromUUIDBasedLog trustmap $ UUIDBased.parseLog Just content + | otherwise -> ChangeFile $ UUIDBased.showLog id $ dropDeadFromMapLog trustmap id $ UUIDBased.parseLog Just content Just NewUUIDBasedLog -> ChangeFile $ - UUIDBased.showLogNew id $ dropDeadFromUUIDBasedLog trustmap $ UUIDBased.parseLogNew Just content + UUIDBased.showLogNew id $ dropDeadFromMapLog trustmap id $ UUIDBased.parseLogNew Just content + Just (ChunkLog _) -> ChangeFile $ + Chunk.showLog $ dropDeadFromMapLog trustmap fst $ Chunk.parseLog content Just (PresenceLog _) -> let newlog = Presence.compactLog $ dropDeadFromPresenceLog trustmap $ Presence.parseLog content in if null newlog @@ -48,8 +51,8 @@ dropDead f content trustmap = case getLogVariety f of Just OtherLog -> PreserveFile Nothing -> PreserveFile -dropDeadFromUUIDBasedLog :: TrustMap -> UUIDBased.Log String -> UUIDBased.Log String -dropDeadFromUUIDBasedLog trustmap = M.filterWithKey $ notDead trustmap . const +dropDeadFromMapLog :: TrustMap -> (k -> UUID) -> M.Map k v -> M.Map k v +dropDeadFromMapLog trustmap getuuid = M.filterWithKey $ \k _v -> notDead trustmap getuuid k {- Presence logs can contain UUIDs or other values. Any line that matches - a dead uuid is dropped; any other values are passed through. -} -- cgit v1.2.3