diff options
author | Joey Hess <joey@kitenet.net> | 2014-09-12 12:26:12 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-09-12 12:26:12 -0400 |
commit | 3afcb1a449ecfee52419767957fa1f06673515b6 (patch) | |
tree | f727f5b1ffe24b1a6769ee38336e2e08e8ab23ab | |
parent | 006e5e7fea3925cd1f4c650cf42b020520742d70 (diff) |
Rather than crashing when there's a problem with the requested bloomfilter capacity/accuracy, fall back to a reasonable default bloom filter size.
-rw-r--r-- | Command/Unused.hs | 7 | ||||
-rw-r--r-- | Utility/Bloom.hs | 4 | ||||
-rw-r--r-- | debian/changelog | 2 |
3 files changed, 10 insertions, 3 deletions
diff --git a/Command/Unused.hs b/Command/Unused.hs index bf98e53bc..c2179447d 100644 --- a/Command/Unused.hs +++ b/Command/Unused.hs @@ -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. diff --git a/Utility/Bloom.hs b/Utility/Bloom.hs index e3000de3d..b0988a8c4 100644 --- a/Utility/Bloom.hs +++ b/Utility/Bloom.hs @@ -9,7 +9,7 @@ module Utility.Bloom ( Bloom, - suggestSizing, + safeSuggestSizing, Hashable, cheapHashes, notElemB, @@ -25,7 +25,7 @@ import qualified Data.BloomFilter as Bloom #else import qualified Data.BloomFilter as Bloom #endif -import Data.BloomFilter.Easy (suggestSizing, Bloom) +import Data.BloomFilter.Easy (safeSuggestSizing, Bloom) import Data.BloomFilter.Hash (Hashable, cheapHashes) import Control.Monad.ST.Safe (ST) diff --git a/debian/changelog b/debian/changelog index 710f72a34..c2e0ea508 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,8 @@ git-annex (5.20140832) UNRELEASED; urgency=medium the repository, rather than just the file's base name. Note that if you're relying on such things to keep files separate with WORM, you should really be using a better backend. + * Rather than crashing when there's a problem with the requested bloomfilter + capacity/accuracy, fall back to a reasonable default bloom filter size. -- Joey Hess <joeyh@debian.org> Thu, 04 Sep 2014 16:17:22 -0400 |