From 8cf937c5d0d1c204631a7bcd38aacc0011133feb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 1 Aug 2014 15:36:11 -0400 Subject: fix chunk=0 Found by testremote --- Remote/Helper/Chunked.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Remote/Helper/Chunked.hs') diff --git a/Remote/Helper/Chunked.hs b/Remote/Helper/Chunked.hs index fcfe06b20..129db3281 100644 --- a/Remote/Helper/Chunked.hs +++ b/Remote/Helper/Chunked.hs @@ -33,6 +33,7 @@ data ChunkConfig = NoChunks | UnpaddedChunks ChunkSize | LegacyChunks ChunkSize + deriving (Show) noChunks :: ChunkConfig -> Bool noChunks NoChunks = True @@ -43,12 +44,14 @@ 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" + Just v -> readsz UnpaddedChunks v "chunk" + Just v -> readsz LegacyChunks v "chunksize" where - readsz v f = case readSize dataUnits v of - Just size | size > 0 -> fromInteger size - _ -> error ("bad " ++ f) + readsz c v f = case readSize dataUnits v of + Just size + | size == 0 -> NoChunks + | size > 0 -> c (fromInteger size) + _ -> error $ "bad configuration " ++ f ++ "=" ++ v -- An infinite stream of chunk keys, starting from chunk 1. newtype ChunkKeyStream = ChunkKeyStream [Key] -- cgit v1.2.3