git-annex/Logs/Multicast.hs
Joey Hess 2fef43dd71
convert all per-uuid log files to use Builder
Mostly didn't push the ByteStrings down very deep, but all of these log
files are not written to frequently at all, so slight remaining
innefficiency doesn't matter.

In Logs.UUID, removed the fixBadUUID code that cleaned up after a bug in
git-annex versions 3.20111105-3.20111110. In the unlikely event that a repo was
last touched by that ancient git-annex version, the descriptions of remotes
would appear missing when used with this version of git-annex. That is such minor
breakage, and so unlikely to still be a problem for any repos, that it was not
worth forward-porting that code to ByteString.
2019-01-09 14:00:35 -04:00

34 lines
851 B
Haskell

{- git-annex multicast fingerprint log
-
- Copyright 2017 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Logs.Multicast (
Fingerprint(..),
recordFingerprint,
knownFingerPrints,
) where
import Annex.Common
import qualified Annex.Branch
import Logs
import Logs.UUIDBased
import qualified Data.Map as M
import Data.ByteString.Builder
newtype Fingerprint = Fingerprint String
deriving (Eq, Read, Show)
recordFingerprint :: Fingerprint -> UUID -> Annex ()
recordFingerprint fp uuid = do
c <- liftIO currentVectorClock
Annex.Branch.change multicastLog $
buildLog (byteString . encodeBS . show)
. changeLog c uuid fp
. parseLog readish . decodeBL
knownFingerPrints :: Annex (M.Map UUID Fingerprint)
knownFingerPrints = simpleMap . parseLog readish . decodeBL <$> Annex.Branch.get activityLog