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