avoid double checksum when downloading VURL from web for 1st time
Sponsored-by: Jack Hill on Patreon
This commit is contained in:
parent
4046f17ca0
commit
1b0de3021a
2 changed files with 23 additions and 25 deletions
|
@ -147,27 +147,28 @@ downloadKey urlincludeexclude key _af dest p vc =
|
|||
)
|
||||
|
||||
postdl v@Verified = return (Just v)
|
||||
postdl v = do
|
||||
when (fromKey keyVariety key == VURLKey) $
|
||||
recordvurlkey
|
||||
return (Just v)
|
||||
|
||||
postdl v
|
||||
-- For a VURL key that was not verified on download,
|
||||
-- need to generate a hashed key for the content downloaded
|
||||
-- from the web, and record it for later use verifying this content.
|
||||
-- from the web, and record it for later use verifying this
|
||||
-- content.
|
||||
--
|
||||
-- But when the VURL key has a known size, and already has a
|
||||
-- recorded hashed key, don't record a new key, since the content
|
||||
-- on the web is expected to be stable for such a key.
|
||||
recordvurlkey = case fromKey keySize key of
|
||||
Nothing -> recordvurlkey' =<< getEquivilantKeys key
|
||||
-- recorded hashed key, don't record a new key, since the
|
||||
-- content on the web is expected to be stable for such a key.
|
||||
| fromKey keyVariety key == VURLKey =
|
||||
case fromKey keySize key of
|
||||
Nothing ->
|
||||
getEquivilantKeys key
|
||||
>>= recordvurlkey
|
||||
Just _ -> do
|
||||
eks <- getEquivilantKeys key
|
||||
if null eks
|
||||
then recordvurlkey' eks
|
||||
else return ()
|
||||
then recordvurlkey eks
|
||||
else return (Just v)
|
||||
| otherwise = return (Just v)
|
||||
|
||||
recordvurlkey' eks = do
|
||||
recordvurlkey eks = do
|
||||
-- Make sure to pick a backend that is cryptographically
|
||||
-- secure.
|
||||
db <- defaultBackend
|
||||
|
@ -178,6 +179,7 @@ downloadKey urlincludeexclude key _af dest p vc =
|
|||
(hashk, _) <- genKey ks nullMeterUpdate b
|
||||
unless (hashk `elem` eks) $
|
||||
setEquivilantKey key hashk
|
||||
return (Just Verified)
|
||||
where
|
||||
ks = KeySource
|
||||
{ keyFilename = mempty -- avoid adding any extension
|
||||
|
|
|
@ -11,11 +11,7 @@ verify the content.
|
|||
The web special remote can hash the content as it's downloading it from the
|
||||
web, and record the resulting hash-based key.
|
||||
|
||||
> Status: Working, but `git-annex addurl --relaxed --verifiable` followed
|
||||
> by `git-annex get` currently does 2 checksums in the get stage; it should
|
||||
> only do one.
|
||||
>
|
||||
> It's not yet possible to migrate an URL key to a VURL key. Should be easy
|
||||
> Status: Working, but it's not yet possible to migrate an URL key to a VURL key. Should be easy
|
||||
> to add support for this. --[[Joey]]
|
||||
|
||||
## handling upgrades
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue