plumb VerifyConfig into retrieveKeyFile
This fixes the recent reversion that annex.verify is not honored, because retrieveChunks was passed RemoteVerify baser, but baser did not have export/import set up. Sponsored-by: Dartmouth College's DANDI project
This commit is contained in:
parent
4bbc6a25fa
commit
f0754a61f5
21 changed files with 64 additions and 55 deletions
|
@ -96,8 +96,8 @@ gen r _ rc gc rs = do
|
|||
, remoteStateHandle = rs
|
||||
}
|
||||
|
||||
downloadKey :: Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Verification
|
||||
downloadKey key _file dest p = do
|
||||
downloadKey :: Key -> AssociatedFile -> FilePath -> MeterUpdate -> VerifyConfig -> Annex Verification
|
||||
downloadKey key _file dest p _ = do
|
||||
get . map (torrentUrlNum . fst . getDownloader) =<< getBitTorrentUrls key
|
||||
-- While bittorrent verifies the hash in the torrent file,
|
||||
-- the torrent file itself is downloaded without verification,
|
||||
|
|
|
@ -529,16 +529,16 @@ lockKey' repo r st@(State connpool duc _ _ _) key callback
|
|||
failedlock = giveup "can't lock content"
|
||||
|
||||
{- Tries to copy a key's content from a remote's annex to a file. -}
|
||||
copyFromRemote :: Remote -> State -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Verification
|
||||
copyFromRemote :: Remote -> State -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> VerifyConfig -> Annex Verification
|
||||
copyFromRemote = copyFromRemote' False
|
||||
|
||||
copyFromRemote' :: Bool -> Remote -> State -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Verification
|
||||
copyFromRemote' forcersync r st key file dest meterupdate = do
|
||||
copyFromRemote' :: Bool -> Remote -> State -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> VerifyConfig -> Annex Verification
|
||||
copyFromRemote' forcersync r st key file dest meterupdate vc = do
|
||||
repo <- getRepo r
|
||||
copyFromRemote'' repo forcersync r st key file dest meterupdate
|
||||
copyFromRemote'' repo forcersync r st key file dest meterupdate vc
|
||||
|
||||
copyFromRemote'' :: Git.Repo -> Bool -> Remote -> State -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Verification
|
||||
copyFromRemote'' repo forcersync r st@(State connpool _ _ _ _) key file dest meterupdate
|
||||
copyFromRemote'' :: Git.Repo -> Bool -> Remote -> State -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> VerifyConfig -> Annex Verification
|
||||
copyFromRemote'' repo forcersync r st@(State connpool _ _ _ _) key file dest meterupdate vc
|
||||
| Git.repoIsHttp repo = do
|
||||
gc <- Annex.getGitConfig
|
||||
ok <- Url.withUrlOptionsPromptingCreds $
|
||||
|
@ -555,12 +555,11 @@ copyFromRemote'' repo forcersync r st@(State connpool _ _ _ _) key file dest met
|
|||
let checksuccess = check >>= \case
|
||||
Just err -> giveup err
|
||||
Nothing -> return True
|
||||
let verify = Annex.Content.RemoteVerify r
|
||||
copier <- mkFileCopier hardlink st
|
||||
(ok, v) <- runTransfer (Transfer Download u (fromKey id key))
|
||||
file Nothing stdRetry $ \p ->
|
||||
metered (Just (combineMeterUpdate p meterupdate)) key $ \_ p' ->
|
||||
copier object dest key p' checksuccess verify
|
||||
copier object dest key p' checksuccess vc
|
||||
if ok
|
||||
then return v
|
||||
else giveup "failed to retrieve content from remote"
|
||||
|
@ -572,9 +571,8 @@ copyFromRemote'' repo forcersync r st@(State connpool _ _ _ _) key file dest met
|
|||
then return v
|
||||
else giveup "failed to retrieve content from remote"
|
||||
else P2PHelper.retrieve
|
||||
(Annex.Content.RemoteVerify r)
|
||||
(\p -> Ssh.runProto r connpool (return (False, UnVerified)) (fallback p))
|
||||
key file dest meterupdate
|
||||
key file dest meterupdate vc
|
||||
| otherwise = giveup "copying from non-ssh, non-http remote not supported"
|
||||
where
|
||||
fallback p = unVerified $ feedprogressback $ \p' -> do
|
||||
|
@ -699,7 +697,7 @@ copyToRemote' repo r st@(State connpool duc _ _ _) key file meterupdate
|
|||
res <- onLocalFast st $ ifM (Annex.Content.inAnnex key)
|
||||
( return True
|
||||
, runTransfer (Transfer Download u (fromKey id key)) file Nothing stdRetry $ \p -> do
|
||||
let verify = Annex.Content.RemoteVerify r
|
||||
let verify = RemoteVerify r
|
||||
copier <- mkFileCopier hardlink st
|
||||
let rsp = RetrievalAllKeysSecure
|
||||
let checksuccess = liftIO checkio >>= \case
|
||||
|
|
|
@ -171,14 +171,14 @@ adjustExportImport' isexport isimport r rs = do
|
|||
, lockContent = if versioned
|
||||
then lockContent r
|
||||
else Nothing
|
||||
, retrieveKeyFile = \k af dest p ->
|
||||
, retrieveKeyFile = \k af dest p vc ->
|
||||
if isimport
|
||||
then supportversionedretrieve k af dest p $
|
||||
then supportversionedretrieve k af dest p vc $
|
||||
retrieveKeyFileFromImport dbv ciddbv k af dest p
|
||||
else if isexport
|
||||
then supportversionedretrieve k af dest p $
|
||||
then supportversionedretrieve k af dest p vc $
|
||||
retrieveKeyFileFromExport dbv k af dest p
|
||||
else retrieveKeyFile r k af dest p
|
||||
else retrieveKeyFile r k af dest p vc
|
||||
, retrieveKeyFileCheap = if versioned
|
||||
then retrieveKeyFileCheap r
|
||||
else Nothing
|
||||
|
@ -369,9 +369,9 @@ adjustExportImport' isexport isimport r rs = do
|
|||
-- versionedExport remotes have a key/value store, so can use
|
||||
-- the usual retrieveKeyFile, rather than an import/export
|
||||
-- variant. However, fall back to that if retrieveKeyFile fails.
|
||||
supportversionedretrieve k af dest p a
|
||||
supportversionedretrieve k af dest p vc a
|
||||
| versionedExport (exportActions r) =
|
||||
retrieveKeyFile r k af dest p
|
||||
retrieveKeyFile r k af dest p vc
|
||||
`catchNonAsync` const a
|
||||
| otherwise = a
|
||||
|
||||
|
|
|
@ -34,8 +34,10 @@ addHooks' r Nothing Nothing = r
|
|||
addHooks' r starthook stophook = r'
|
||||
where
|
||||
r' = r
|
||||
{ storeKey = \k f p -> wrapper $ storeKey r k f p
|
||||
, retrieveKeyFile = \k f d p -> wrapper $ retrieveKeyFile r k f d p
|
||||
{ storeKey = \k f p ->
|
||||
wrapper $ storeKey r k f p
|
||||
, retrieveKeyFile = \k f d p vc ->
|
||||
wrapper $ retrieveKeyFile r k f d p vc
|
||||
, retrieveKeyFileCheap = case retrieveKeyFileCheap r of
|
||||
Just a -> Just $ \k af f -> wrapper $ a k af f
|
||||
Nothing -> Nothing
|
||||
|
|
|
@ -40,8 +40,8 @@ store runner k af p = do
|
|||
Just False -> giveup "Transfer failed"
|
||||
Nothing -> remoteUnavail
|
||||
|
||||
retrieve :: VerifyConfig -> (MeterUpdate -> ProtoRunner (Bool, Verification)) -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Verification
|
||||
retrieve verifyconfig runner k af dest p = do
|
||||
retrieve :: (MeterUpdate -> ProtoRunner (Bool, Verification)) -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> VerifyConfig -> Annex Verification
|
||||
retrieve runner k af dest p verifyconfig = do
|
||||
iv <- startVerifyKeyContentIncrementally verifyconfig k
|
||||
metered (Just p) k $ \m p' ->
|
||||
runner p' (P2P.get dest k iv af m p') >>= \case
|
||||
|
|
|
@ -146,8 +146,8 @@ fileRetriever' a k m miv callback = do
|
|||
-}
|
||||
storeKeyDummy :: Key -> AssociatedFile -> MeterUpdate -> Annex ()
|
||||
storeKeyDummy _ _ _ = error "missing storeKey implementation"
|
||||
retrieveKeyFileDummy :: Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Verification
|
||||
retrieveKeyFileDummy _ _ _ _ = error "missing retrieveKeyFile implementation"
|
||||
retrieveKeyFileDummy :: Key -> AssociatedFile -> FilePath -> MeterUpdate -> VerifyConfig -> Annex Verification
|
||||
retrieveKeyFileDummy _ _ _ _ _ = error "missing retrieveKeyFile implementation"
|
||||
removeKeyDummy :: Key -> Annex ()
|
||||
removeKeyDummy _ = error "missing removeKey implementation"
|
||||
checkPresentDummy :: Key -> Annex Bool
|
||||
|
@ -192,7 +192,7 @@ specialRemote' cfg c storer retriever remover checkpresent baser = encr
|
|||
where
|
||||
encr = baser
|
||||
{ storeKey = \k _f p -> cip >>= storeKeyGen k p
|
||||
, retrieveKeyFile = \k _f d p -> cip >>= retrieveKeyFileGen k d p
|
||||
, retrieveKeyFile = \k _f d p vc -> cip >>= retrieveKeyFileGen k d p vc
|
||||
, retrieveKeyFileCheap = case retrieveKeyFileCheap baser of
|
||||
Nothing -> Nothing
|
||||
Just a
|
||||
|
@ -241,11 +241,9 @@ specialRemote' cfg c storer retriever remover checkpresent baser = encr
|
|||
enck = maybe id snd enc
|
||||
|
||||
-- call retriever to get chunks; decrypt them; stream to dest file
|
||||
retrieveKeyFileGen k dest p enc =
|
||||
retrieveKeyFileGen k dest p vc enc =
|
||||
displayprogress p k Nothing $ \p' ->
|
||||
retrieveChunks retriever
|
||||
(uuid baser)
|
||||
(RemoteVerify baser)
|
||||
retrieveChunks retriever (uuid baser) vc
|
||||
chunkconfig enck k dest p' enc encr
|
||||
where
|
||||
enck = maybe id snd enc
|
||||
|
|
|
@ -113,8 +113,8 @@ httpAlsoSetup _ (Just u) _ c gc = do
|
|||
gitConfigSpecialRemote u c' [("httpalso", "true")]
|
||||
return (c', u)
|
||||
|
||||
downloadKey :: Maybe URLString -> LearnedLayout -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Verification
|
||||
downloadKey baseurl ll key _af dest p = do
|
||||
downloadKey :: Maybe URLString -> LearnedLayout -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> VerifyConfig -> Annex Verification
|
||||
downloadKey baseurl ll key _af dest p _vc = do
|
||||
downloadAction dest p key (keyUrlAction baseurl ll key)
|
||||
return UnVerified
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ module Remote.P2P (
|
|||
import Annex.Common
|
||||
import qualified Annex
|
||||
import qualified P2P.Protocol as P2P
|
||||
import qualified Annex.Content
|
||||
import P2P.Address
|
||||
import P2P.Annex
|
||||
import P2P.IO
|
||||
|
@ -57,7 +56,7 @@ chainGen addr r u rc gc rs = do
|
|||
, cost = cst
|
||||
, name = Git.repoDescribe r
|
||||
, storeKey = store (const protorunner)
|
||||
, retrieveKeyFile = retrieve (Annex.Content.RemoteVerify this) (const protorunner)
|
||||
, retrieveKeyFile = retrieve (const protorunner)
|
||||
, retrieveKeyFileCheap = Nothing
|
||||
, retrievalSecurityPolicy = RetrievalAllKeysSecure
|
||||
, removeKey = remove protorunner
|
||||
|
|
|
@ -144,8 +144,8 @@ store rs hdl k _f _p = sendAnnex k noop $ \src ->
|
|||
(giveup "tahoe failed to store content")
|
||||
(\cap -> storeCapability rs k cap)
|
||||
|
||||
retrieve :: RemoteStateHandle -> TahoeHandle -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Verification
|
||||
retrieve rs hdl k _f d _p = do
|
||||
retrieve :: RemoteStateHandle -> TahoeHandle -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> VerifyConfig -> Annex Verification
|
||||
retrieve rs hdl k _f d _p _ = do
|
||||
go =<< getCapability rs k
|
||||
-- Tahoe verifies the content it retrieves using cryptographically
|
||||
-- secure methods.
|
||||
|
|
|
@ -81,8 +81,8 @@ gen r _ rc gc rs = do
|
|||
, remoteStateHandle = rs
|
||||
}
|
||||
|
||||
downloadKey :: Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Verification
|
||||
downloadKey key _af dest p = do
|
||||
downloadKey :: Key -> AssociatedFile -> FilePath -> MeterUpdate -> VerifyConfig -> Annex Verification
|
||||
downloadKey key _af dest p _ = do
|
||||
get =<< getWebUrls key
|
||||
return UnVerified
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue