summaryrefslogtreecommitdiff
path: root/Limit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-02-27 15:02:38 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-02-27 15:02:44 -0400
commit5096cb295c9068ab02aa3aa1bf8eb70b2ed89ede (patch)
treeda116313c5e510e36a17001116655e95f945ea7a /Limit.hs
parent9cce9dd3735b98c92400e10e08c2723e5bf7f118 (diff)
securehash matching
Added --securehash option to match files using a secure hash function, and corresponding securehash preferred content expression. This commit was sponsored by Ethan Aubin.
Diffstat (limited to 'Limit.hs')
-rw-r--r--Limit.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/Limit.hs b/Limit.hs
index 1485b4bce..97e3653b1 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -1,6 +1,6 @@
{- user-specified limits on files to act on
-
- - Copyright 2011-2016 Joey Hess <id@joeyh.name>
+ - Copyright 2011-2017 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -255,6 +255,13 @@ limitInBackend name = Right $ const $ checkKey check
check key = pure $ keyVariety key == variety
variety = parseKeyVariety name
+{- Adds a limit to skip files not using a secure hash. -}
+addSecureHash :: Annex ()
+addSecureHash = addLimit $ Right limitSecureHash
+
+limitSecureHash :: MatchFiles Annex
+limitSecureHash _ = checkKey $ pure . cryptographicallySecure . keyVariety
+
{- Adds a limit to skip files that are too large or too small -}
addLargerThan :: String -> Annex ()
addLargerThan = addLimit . limitSize (>)