rename fsckKey to verifyKeyContent
No behavior changes.
This commit is contained in:
parent
49841bbd64
commit
cad3349001
8 changed files with 20 additions and 17 deletions
|
@ -104,7 +104,7 @@ startDistributionDownload d = go =<< liftIO . newVersionLocation d =<< liftIO ol
|
|||
{- Called once the download is done.
|
||||
- Passed an action that can be used to clean up the downloaded file.
|
||||
-
|
||||
- Fsck the key to verify the download.
|
||||
- Verifies the content of the downloaded key.
|
||||
-}
|
||||
distributionDownloadComplete :: GitAnnexDistribution -> FilePath -> Assistant () -> Transfer -> Assistant ()
|
||||
distributionDownloadComplete d dest cleanup t
|
||||
|
@ -117,9 +117,9 @@ distributionDownloadComplete d dest cleanup t
|
|||
k = distributionKey d
|
||||
fsckit f = case Backend.maybeLookupBackendName (Types.Key.keyBackendName k) of
|
||||
Nothing -> return $ Just f
|
||||
Just b -> case Types.Backend.fsckKey b of
|
||||
Just b -> case Types.Backend.verifyKeyContent b of
|
||||
Nothing -> return $ Just f
|
||||
Just a -> ifM (a k f)
|
||||
Just verifier -> ifM (verifier k f)
|
||||
( return $ Just f
|
||||
, return Nothing
|
||||
)
|
||||
|
|
|
@ -53,7 +53,7 @@ genBackend :: Hash -> Backend
|
|||
genBackend hash = Backend
|
||||
{ name = hashName hash
|
||||
, getKey = keyValue hash
|
||||
, fsckKey = Just $ checkKeyChecksum hash
|
||||
, verifyKeyContent = Just $ checkKeyChecksum hash
|
||||
, canUpgradeKey = Just needsUpgrade
|
||||
, fastMigrate = Just trivialMigrate
|
||||
, isStableKey = const True
|
||||
|
|
|
@ -22,7 +22,7 @@ backend :: Backend
|
|||
backend = Backend
|
||||
{ name = "URL"
|
||||
, getKey = const $ return Nothing
|
||||
, fsckKey = Nothing
|
||||
, verifyKeyContent = Nothing
|
||||
, canUpgradeKey = Nothing
|
||||
, fastMigrate = Nothing
|
||||
-- The content of an url can change at any time, so URL keys are
|
||||
|
|
|
@ -21,7 +21,7 @@ backend :: Backend
|
|||
backend = Backend
|
||||
{ name = "WORM"
|
||||
, getKey = keyValue
|
||||
, fsckKey = Nothing
|
||||
, verifyKeyContent = Nothing
|
||||
, canUpgradeKey = Nothing
|
||||
, fastMigrate = Nothing
|
||||
, isStableKey = const True
|
||||
|
|
|
@ -349,12 +349,15 @@ checkBackendOr :: (Key -> Annex String) -> Backend -> Key -> FilePath -> Annex B
|
|||
checkBackendOr bad backend key file =
|
||||
checkBackendOr' bad backend key file (return True)
|
||||
|
||||
-- The postcheck action is run after the content is verified,
|
||||
-- in order to detect situations where the file is changed while being
|
||||
-- verified (particularly in direct mode).
|
||||
checkBackendOr' :: (Key -> Annex String) -> Backend -> Key -> FilePath -> Annex Bool -> Annex Bool
|
||||
checkBackendOr' bad backend key file postcheck =
|
||||
case Types.Backend.fsckKey backend of
|
||||
case Types.Backend.verifyKeyContent backend of
|
||||
Nothing -> return True
|
||||
Just a -> do
|
||||
ok <- a key file
|
||||
Just verifier -> do
|
||||
ok <- verifier key file
|
||||
ifM postcheck
|
||||
( do
|
||||
unless ok $ do
|
||||
|
|
|
@ -70,13 +70,13 @@ start key = fieldTransfer Download key $ \_p ->
|
|||
Nothing -> do
|
||||
warning "recvkey: received key from direct mode repository using unknown backend; cannot check; discarding"
|
||||
return False
|
||||
Just backend -> maybe (return True) runfsck
|
||||
(Types.Backend.fsckKey backend)
|
||||
Just backend -> maybe (return True) runverify
|
||||
(Types.Backend.verifyKeyContent backend)
|
||||
else do
|
||||
warning "recvkey: received key with wrong size; discarding"
|
||||
return False
|
||||
where
|
||||
runfsck check = ifM (check key tmp)
|
||||
runverify check = ifM (check key tmp)
|
||||
( return True
|
||||
, do
|
||||
warning "recvkey: received key from direct mode repository seems to have changed as it was transferred; discarding"
|
||||
|
|
|
@ -14,7 +14,7 @@ import qualified Remote
|
|||
import qualified Types.Remote as Remote
|
||||
import Types
|
||||
import Types.Key (key2file, keyBackendName, keySize)
|
||||
import Types.Backend (getKey, fsckKey)
|
||||
import Types.Backend (getKey, verifyKeyContent)
|
||||
import Types.KeySource
|
||||
import Annex.Content
|
||||
import Backend
|
||||
|
@ -156,9 +156,9 @@ test st r k =
|
|||
(== Right b) <$> Remote.hasKey r k
|
||||
fsck = case maybeLookupBackendName (keyBackendName k) of
|
||||
Nothing -> return True
|
||||
Just b -> case fsckKey b of
|
||||
Just b -> case verifyKeyContent b of
|
||||
Nothing -> return True
|
||||
Just fscker -> fscker k (key2file k)
|
||||
Just verifier -> verifier k (key2file k)
|
||||
get = getViaTmp k $ \dest ->
|
||||
Remote.retrieveKeyFile r k Nothing dest nullMeterUpdate
|
||||
store = Remote.storeKey r k Nothing nullMeterUpdate
|
||||
|
|
|
@ -15,8 +15,8 @@ import Types.KeySource
|
|||
data BackendA a = Backend
|
||||
{ name :: String
|
||||
, getKey :: KeySource -> a (Maybe Key)
|
||||
-- Checks the content of a key.
|
||||
, fsckKey :: Maybe (Key -> FilePath -> a Bool)
|
||||
-- Verifies the content of a key.
|
||||
, verifyKeyContent :: Maybe (Key -> FilePath -> a Bool)
|
||||
-- Checks if a key can be upgraded to a better form.
|
||||
, canUpgradeKey :: Maybe (Key -> Bool)
|
||||
-- Checks if there is a fast way to migrate a key to a different
|
||||
|
|
Loading…
Reference in a new issue