{- git-annex chunked remotes - - Copyright 2012-2014 Joey Hess - - Licensed under the GNU GPL version 3 or higher. -} module Remote.Helper.Chunked where import Utility.DataUnits import Types.Remote import qualified Data.Map as M import Data.Int type ChunkSize = Int64 data ChunkConfig = NoChunks | UnpaddedChunks ChunkSize | LegacyChunks ChunkSize chunkConfig :: RemoteConfig -> ChunkConfig chunkConfig m = case M.lookup "chunksize" m of Nothing -> case M.lookup "chunk" m of Nothing -> NoChunks Just v -> UnpaddedChunks $ readsz v "chunk" Just v -> LegacyChunks $ readsz v "chunksize" where readsz v f = case readSize dataUnits v of Just size | size > 0 -> fromInteger size _ -> error ("bad " ++ f)