support incremental verification when retrieving from export/import remotes

None of the special remotes do it yet, but this lays the groundwork.

Added MustFinishIncompleteVerify so that, when an incremental verify is
started but not complete, it can be forced to finish it. Otherwise, it
would have skipped doing it when verification is disabled, but
verification must always be done when retrievin from export remotes
since files can be modified during retrieval.

Note that retrieveExportWithContentIdentifier doesn't support incremental
verification yet. And I'm not sure if it can -- it doesn't know the Key
before it downloads the content. It seems a new API call would need to
be split out of that, which is provided with the key.

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2022-05-09 12:25:04 -04:00
parent 52b768db45
commit 90950a37e5
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
11 changed files with 42 additions and 22 deletions

View file

@ -208,12 +208,15 @@ data Verification
-- again. The verification does not need to use a
-- cryptographically secure hash, but the hash does need to
-- have preimage resistance.
| MustVerify
-- ^ Content likely to have been altered during transfer,
-- verify even if verification is normally disabled
| IncompleteVerify IncrementalVerifier
-- ^ Content was partially verified during transfer, but
-- the verification is not complete.
| MustVerify
-- ^ Content likely to have been altered during transfer,
-- verify even if verification is normally disabled
| MustFinishIncompleteVerify IncrementalVerifier
-- ^ Content likely to have been altered during transfer,
-- finish verification even if verification is normally disabled.
unVerified :: Monad m => m a -> m (a, Verification)
unVerified a = do
@ -262,7 +265,7 @@ data ExportActions a = ExportActions
-- (The MeterUpdate does not need to be used if it writes
-- sequentially to the file.)
-- Throws exception on failure.
, retrieveExport :: Key -> ExportLocation -> FilePath -> MeterUpdate -> a ()
, retrieveExport :: Key -> ExportLocation -> FilePath -> MeterUpdate -> a Verification
-- Removes an exported file (succeeds if the contents are not present)
-- Can throw exception if unable to access remote, or if remote
-- refuses to remove the content.