From 2a4a641a3c940a652f62371f417433b47f7f3e79 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 16 Jun 2015 18:38:12 -0400 Subject: use bloom filter in second pass of sync --all --content This is needed because when preferred content matches on files, the second pass would otherwise want to drop all keys. Using a bloom filter avoids this, and in the case of a false positive, a key will be left undropped that preferred content would allow dropping. Chances of that happening are a mere 1 in 1 million. --- Annex/BloomFilter.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Annex') diff --git a/Annex/BloomFilter.hs b/Annex/BloomFilter.hs index 3ac81fa58..5773a88ee 100644 --- a/Annex/BloomFilter.hs +++ b/Annex/BloomFilter.hs @@ -40,11 +40,11 @@ bloomBitsHashes = do - Once the action completes, the mutable filter is frozen - for later use. -} -genBloomFilter :: Hashable v => ((v -> Annex ()) -> Annex b) -> Annex (Bloom v) +genBloomFilter :: Hashable v => ((v -> Annex ()) -> Annex ()) -> Annex (Bloom v) genBloomFilter populate = do (numbits, numhashes) <- bloomBitsHashes bloom <- lift $ newMB (cheapHashes numhashes) numbits - _ <- populate $ \v -> lift $ insertMB bloom v + populate $ \v -> lift $ insertMB bloom v lift $ unsafeFreezeMB bloom where lift = liftIO . stToIO -- cgit v1.2.3