summaryrefslogtreecommitdiff
path: root/Logs/Chunk
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-07-24 16:23:36 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-07-24 16:23:36 -0400
commit2b414feaf2d20452794d0cdd608c6dd91feb1ec1 (patch)
tree16f4caafc5158227eda6b36462b93a9c3f35173f /Logs/Chunk
parent35b31b00e4efbf84bcfb814acc477bbb89b50107 (diff)
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.
Diffstat (limited to 'Logs/Chunk')
-rw-r--r--Logs/Chunk/Pure.hs32
1 files changed, 32 insertions, 0 deletions
diff --git a/Logs/Chunk/Pure.hs b/Logs/Chunk/Pure.hs
new file mode 100644
index 000000000..09e871c38
--- /dev/null
+++ b/Logs/Chunk/Pure.hs
@@ -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