summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-08-01 15:36:11 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-08-01 15:36:11 -0400
commit8cf937c5d0d1c204631a7bcd38aacc0011133feb (patch)
treed439f3ed26b6116aa0893e33f123a99a6916e437 /Remote
parent17e04a5593eb41462fa7fb1a8f34af527d249ab7 (diff)
fix chunk=0
Found by testremote
Diffstat (limited to 'Remote')
-rw-r--r--Remote/Helper/Chunked.hs13
1 files changed, 8 insertions, 5 deletions
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]