summaryrefslogtreecommitdiff
path: root/Limit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-22 16:35:32 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-22 16:35:32 -0400
commit180fbceee03badc450c84c28ef8219fa68d80bd6 (patch)
tree1739e92f46067ae0be84af6789b3d3b9adb09ee1 /Limit.hs
parent9a5de318d15f0234080a6f0bd802fe073cf57334 (diff)
add "unused" preferred content expression
With a really nice optimisation that keeps it from having any overhead in normal operation! This commit was sponsored by Ulises Vitulli.
Diffstat (limited to 'Limit.hs')
-rw-r--r--Limit.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/Limit.hs b/Limit.hs
index 6ce444325..8250544a4 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -30,6 +30,7 @@ import Types.Group
import Types.FileMatcher
import Types.Limit
import Logs.Group
+import Logs.Unused
import Utility.HumanTime
import Utility.DataUnits
@@ -199,6 +200,15 @@ limitLackingCopies approx want = case readish want of
return $ numcopies - length us >= needed
approxNumCopies = fromMaybe defaultNumCopies <$> getGlobalNumCopies
+{- Match keys that are unused.
+ -
+ - This has a nice optimisation: When a file exists,
+ - its key is obviously not unused.
+ -}
+limitUnused :: MatchFiles
+limitUnused _ (MatchingFile _) = return False
+limitUnused _ (MatchingKey k) = S.member k <$> unusedKeys
+
{- Adds a limit to skip files not believed to be present in all
- repositories in the specified group. -}
addInAllGroup :: String -> Annex ()