diff --git a/Remote/Web.hs b/Remote/Web.hs index 40bcfc3494..09efcc55e5 100644 --- a/Remote/Web.hs +++ b/Remote/Web.hs @@ -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. + -- + -- 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. + | 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 (Just v) + | otherwise = return (Just 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. - -- - -- 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 - Just _ -> do - eks <- getEquivilantKeys key - if null eks - then recordvurlkey' eks - else return () - - 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 diff --git a/doc/todo/verified_relaxed_urls.mdwn b/doc/todo/verified_relaxed_urls.mdwn index 6be4900eb3..30f83bff44 100644 --- a/doc/todo/verified_relaxed_urls.mdwn +++ b/doc/todo/verified_relaxed_urls.mdwn @@ -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