summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-06-16 19:04:20 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-06-16 19:04:20 -0400
commitb6751c0a7cff4efc80425ae811a37aba65b55a01 (patch)
tree63593eb0927fcdb437d33a4afb2c7fa9998855cb
parent87ec070e779d364952a2854dfc0f05028c0493f1 (diff)
avoid building unused bloomfilter when run without --all
-rw-r--r--Command/Sync.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index eb6bbcea4..9ad0b8deb 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -379,7 +379,10 @@ newer remote b = do
seekSyncContent :: [Remote] -> Annex Bool
seekSyncContent rs = do
mvar <- liftIO newEmptyMVar
- bloom <- genBloomFilter (seekworktree mvar [])
+ bloom <- ifM (Annex.getFlag "all")
+ ( Just <$> genBloomFilter (seekworktree mvar [])
+ , seekworktree mvar [] (const noop) >> pure Nothing
+ )
withKeyOptions' False (seekkeys mvar bloom) (const noop) []
liftIO $ not <$> isEmptyMVar mvar
where
@@ -391,7 +394,7 @@ seekSyncContent rs = do
void $ liftIO $ tryPutMVar mvar ()
syncFile ebloom rs af k
-syncFile :: Either (Bloom Key) (Key -> Annex ()) -> [Remote] -> AssociatedFile -> Key -> Annex ()
+syncFile :: Either (Maybe (Bloom Key)) (Key -> Annex ()) -> [Remote] -> AssociatedFile -> Key -> Annex ()
syncFile ebloom rs af k = do
locs <- loggedLocations k
let (have, lack) = partition (\r -> Remote.uuid r `elem` locs) rs
@@ -411,7 +414,8 @@ syncFile ebloom rs af k = do
-- When there's a false positive in the bloom filter, the result
-- is keeping a key that preferred content doesn't really want.
seenbloom <- case ebloom of
- Left bloom -> pure (elemB k bloom)
+ Left Nothing -> pure False
+ Left (Just bloom) -> pure (elemB k bloom)
Right bloomfeeder -> bloomfeeder k >> return False
unless seenbloom $
-- Using callCommandAction rather than