diff options
author | Joey Hess <joey@kitenet.net> | 2014-07-28 13:19:08 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-07-28 13:19:08 -0400 |
commit | c25686d17f4b1c7850b8b733b5e63cb829becb3f (patch) | |
tree | f8aded3f06947a194a51d65659d6c02b470dafa8 /Logs/Chunk.hs | |
parent | 188fbb1d937db0f63841dcc55cea9999e16aff52 (diff) |
add ChunkMethod type and make Logs.Chunk use it, rather than assuming fixed size chunks (so eg, rolling hash chunks can be supported later)
If a newer git-annex starts logging something else in the chunk log, it
won't be used by this version, but it will be preserved when updating the
log.
Diffstat (limited to 'Logs/Chunk.hs')
-rw-r--r-- | Logs/Chunk.hs | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/Logs/Chunk.hs b/Logs/Chunk.hs index 76da50947..a3e18efc1 100644 --- a/Logs/Chunk.hs +++ b/Logs/Chunk.hs @@ -15,7 +15,14 @@ - Licensed under the GNU GPL version 3 or higher. -} -module Logs.Chunk where +module Logs.Chunk ( + ChunkMethod(..), + ChunkSize, + ChunkCount, + chunksStored, + chunksRemoved, + getCurrentChunks, +) where import Common.Annex import Logs @@ -26,19 +33,19 @@ import Logs.Chunk.Pure import qualified Data.Map as M import Data.Time.Clock.POSIX -chunksStored :: UUID -> Key -> ChunkSize -> ChunkCount -> Annex () -chunksStored u k chunksize chunkcount = do +chunksStored :: UUID -> Key -> ChunkMethod -> ChunkCount -> Annex () +chunksStored u k chunkmethod chunkcount = do ts <- liftIO getPOSIXTime Annex.Branch.change (chunkLogFile k) $ - showLog . changeMapLog ts (u, chunksize) chunkcount . parseLog + showLog . changeMapLog ts (u, chunkmethod) chunkcount . parseLog -chunksRemoved :: UUID -> Key -> ChunkSize -> Annex () -chunksRemoved u k chunksize = chunksStored u k chunksize 0 +chunksRemoved :: UUID -> Key -> ChunkMethod -> Annex () +chunksRemoved u k chunkmethod = chunksStored u k chunkmethod 0 -getCurrentChunks :: UUID -> Key -> Annex [(ChunkSize, ChunkCount)] +getCurrentChunks :: UUID -> Key -> Annex [(ChunkMethod, ChunkCount)] getCurrentChunks u k = select . parseLog <$> Annex.Branch.get (chunkLogFile k) where - select = filter (\(_sz, ct) -> ct > 0) - . map (\((_ku, sz), l) -> (sz, value l)) + select = filter (\(_m, ct) -> ct > 0) + . map (\((_ku, m), l) -> (m, value l)) . M.toList - . M.filterWithKey (\(ku, _sz) _ -> ku == u) + . M.filterWithKey (\(ku, _m) _ -> ku == u) |