Rather than crashing when there's a problem with the requested bloomfilter capacity/accuracy, fall back to a reasonable default bloom filter size.

This commit is contained in:
Joey Hess 2014-09-12 12:26:12 -04:00
parent eb26f00c04
commit 7482166180
3 changed files with 10 additions and 3 deletions

View file

@ -189,7 +189,12 @@ bloomBitsHashes :: Annex (Int, Int)
bloomBitsHashes = do
capacity <- bloomCapacity
accuracy <- bloomAccuracy
return $ suggestSizing capacity (1/ fromIntegral accuracy)
case safeSuggestSizing capacity (1 / fromIntegral accuracy) of
Left e -> do
warning $ "bloomfilter " ++ e ++ "; falling back to sane value"
-- precaulculated value for 500000 (1/1000)
return (8388608,10)
Right v -> return v
{- Creates a bloom filter, and runs an action, such as withKeysReferenced,
- to populate it.