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.
This commit is contained in:
Joey Hess 2014-07-24 16:23:36 -04:00
parent bbdb2c04d5
commit e2c44bf656
8 changed files with 134 additions and 39 deletions

32
Logs/Chunk/Pure.hs Normal file
View file

@ -0,0 +1,32 @@
{- Chunk logs, pure operations.
-
- Copyright 2014 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Logs.Chunk.Pure where
import Common.Annex
import Logs.MapLog
import Data.Int
type ChunkSize = Int64
type ChunkCount = Integer
type ChunkLog = MapLog (UUID, ChunkSize) ChunkCount
parseLog :: String -> ChunkLog
parseLog = parseMapLog fieldparser valueparser
where
fieldparser s =
let (u,sz) = separate (== ':') s
in (,) <$> pure (toUUID u) <*> readish sz
valueparser = readish
showLog :: ChunkLog -> String
showLog = showMapLog fieldshower valueshower
where
fieldshower (u, sz) = fromUUID u ++ ':' : show sz
valueshower = show