refactoring
This commit is contained in:
parent
9c2c3002a6
commit
1704b5e327
3 changed files with 25 additions and 14 deletions
12
Backend.hs
12
Backend.hs
|
@ -10,13 +10,14 @@
|
|||
module Backend (
|
||||
builtinList,
|
||||
defaultBackend,
|
||||
defaultHashBackend,
|
||||
hashBackend,
|
||||
genKey,
|
||||
getBackend,
|
||||
chooseBackend,
|
||||
lookupBackendVariety,
|
||||
lookupBuiltinBackendVariety,
|
||||
maybeLookupBackendVariety,
|
||||
unknownBackendVarietyMessage,
|
||||
isStableKey,
|
||||
isCryptographicallySecureKey,
|
||||
isCryptographicallySecure,
|
||||
|
@ -54,6 +55,15 @@ defaultBackend = maybe cache return =<< Annex.getState Annex.backend
|
|||
valid name = not (null name)
|
||||
lookupname = lookupBackendVariety . parseKeyVariety . encodeBS
|
||||
|
||||
{- A hashing backend. Takes git config into account, but
|
||||
- guarantees the backend is cryptographically secure. -}
|
||||
hashBackend :: Annex Backend
|
||||
hashBackend = do
|
||||
db <- defaultBackend
|
||||
return $ if isCryptographicallySecure db
|
||||
then db
|
||||
else defaultHashBackend
|
||||
|
||||
{- Generates a key for a file. -}
|
||||
genKey :: KeySource -> MeterUpdate -> Backend -> Annex (Key, Backend)
|
||||
genKey source meterupdate b = case B.genKey b of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue