support VURL backend

Not yet implemented is recording hashes on download from web and
verifying hashes.

addurl --verifiable option added with -V short option because I
expect a lot of people will want to use this.

It seems likely that --verifiable will become the default eventually,
and possibly rather soon. While old git-annex versions don't support
VURL, that doesn't prevent using them with keys that use VURL. Of
course, they won't verify the content on transfer, and fsck will warn
that it doesn't know about VURL. So there's not much problem with
starting to use VURL even when interoperating with old versions.

Sponsored-by: Joshua Antonishen on Patreon
This commit is contained in:
Joey Hess 2024-02-29 13:26:06 -04:00
parent 8f40e0269b
commit 0f7143d226
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
12 changed files with 127 additions and 33 deletions

View file

@ -1,6 +1,6 @@
{- git-annex Key data type
-
- Copyright 2011-2020 Joey Hess <id@joeyh.name>
- Copyright 2011-2024 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -218,6 +218,7 @@ data KeyVariety
| MD5Key HasExt
| WORMKey
| URLKey
| VURLKey
-- A key that is handled by some external backend.
| ExternalKey S.ByteString HasExt
-- Some repositories may contain keys of other varieties,
@ -251,6 +252,7 @@ hasExt (SHA1Key (HasExt b)) = b
hasExt (MD5Key (HasExt b)) = b
hasExt WORMKey = False
hasExt URLKey = False
hasExt VURLKey = False
hasExt (ExternalKey _ (HasExt b)) = b
hasExt (OtherKey s) = (snd <$> S8.unsnoc s) == Just 'E'
@ -279,6 +281,7 @@ formatKeyVariety v = case v of
MD5Key e -> adde e "MD5"
WORMKey -> "WORM"
URLKey -> "URL"
VURLKey -> "VURL"
ExternalKey s e -> adde e ("X" <> s)
OtherKey s -> s
where
@ -343,6 +346,7 @@ parseKeyVariety "MD5" = MD5Key (HasExt False)
parseKeyVariety "MD5E" = MD5Key (HasExt True)
parseKeyVariety "WORM" = WORMKey
parseKeyVariety "URL" = URLKey
parseKeyVariety "VURL" = VURLKey
parseKeyVariety b
| "X" `S.isPrefixOf` b =
let b' = S.tail b