pruneTmpWorkDirBefore,
isUnmodified,
isUnmodifiedCheap,
+ verifyKeyContentPostRetrieval,
verifyKeyContent,
VerifyConfig(..),
Verification(..),
_ -> MustVerify
else verification
if ok
- then ifM (verifyKeyContent rsp v verification' key tmpfile)
+ then ifM (verifyKeyContentPostRetrieval rsp v verification' key tmpfile)
( pruneTmpWorkDirBefore tmpfile (moveAnnex key af)
, do
warning "verification of content failed"
import Annex.Common
import Annex.Verify
-import Types.Remote
import Annex.InodeSentinal
import Utility.InodeCache
isUnmodifiedLowLevel addinodecaches key f fc ic =
isUnmodifiedCheapLowLevel fc ic <||> expensivecheck
where
- expensivecheck = ifM (verifyKeyContent RetrievalAllKeysSecure AlwaysVerify UnVerified key f)
+ expensivecheck = ifM (verifyKeyContent key f)
( do
-- The file could have been modified while it was
-- being verified. Detect that.
module Annex.Verify (
VerifyConfig(..),
shouldVerify,
+ verifyKeyContentPostRetrieval,
verifyKeyContent,
Verification(..),
unVerified,
- If the RetrievalSecurityPolicy requires verification and the key's
- backend doesn't support it, the verification will fail.
-}
-verifyKeyContent :: RetrievalSecurityPolicy -> VerifyConfig -> Verification -> Key -> RawFilePath -> Annex Bool
-verifyKeyContent rsp v verification k f = case (rsp, verification) of
+verifyKeyContentPostRetrieval :: RetrievalSecurityPolicy -> VerifyConfig -> Verification -> Key -> RawFilePath -> Annex Bool
+verifyKeyContentPostRetrieval rsp v verification k f = case (rsp, verification) of
(_, Verified) -> return True
(RetrievalVerifiableKeysSecure, _) -> ifM (isVerifiable k)
( verify
)
(_, MustVerify) -> verify
where
- verify = enteringStage VerifyStage $ verifysize <&&> verifycontent
+ verify = enteringStage VerifyStage $ verifyKeyContent k f
+
+verifyKeyContent :: Key -> RawFilePath -> Annex Bool
+verifyKeyContent k f = verifysize <&&> verifycontent
+ where
verifysize = case fromKey keySize k of
Nothing -> return True
Just size -> do
where
src' = toRawFilePath src
go key = starting "reinject" ai si $
- ifM (verifyKeyContent RetrievalAllKeysSecure DefaultVerify UnVerified key src')
+ ifM (verifyKeyContent key src')
( perform src' key
, giveup $ src ++ " does not have expected content of " ++ dest
)
liftIO $ hClose h
tryNonAsync (Remote.retrieveExport ea k testexportlocation tmp nullMeterUpdate) >>= \case
Left _ -> return False
- Right () -> verifyKeyContent RetrievalAllKeysSecure AlwaysVerify UnVerified k (toRawFilePath tmp)
+ Right () -> verifyKeyContentPostRetrieval RetrievalAllKeysSecure AlwaysVerify UnVerified k (toRawFilePath tmp)
checkpresentexport ea k = Remote.checkPresentExport ea k testexportlocation
removeexport ea k = Remote.removeExport ea k testexportlocation
removeexportdirectory ea = case Remote.removeExportDirectory ea of