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.
This commit is contained in:
Joey Hess 2017-02-27 15:02:38 -04:00
parent 31275754f5
commit 49114cf4ea
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
7 changed files with 27 additions and 1 deletions

View file

@ -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 (>)