as suggested by @reynir: verify -> verify_sha256

This commit is contained in:
Hannes Mehnert 2022-10-28 14:58:58 +02:00
parent 1ff5c7e1b6
commit d143e9b766
2 changed files with 11 additions and 9 deletions

View file

@ -9,11 +9,13 @@ let check =
in
Key.(create "check" Arg.(flag doc))
let verify =
let verify_sha256 =
let doc =
Key.Arg.info ~doc:"Verify the cache contents" ["verify"]
Key.Arg.info ~doc:"Verify the SHA256 checksums of the cache contents, and \
re-build the other checksum caches."
["verify-sha256"]
in
Key.(create "verify" Arg.(flag doc))
Key.(create "verify-sha256" Arg.(flag doc))
let remote =
let doc =
@ -67,7 +69,7 @@ let ignore_local_git =
let mirror =
foreign "Unikernel.Make"
~keys:[ Key.v check ; Key.v verify ; Key.v remote ;
~keys:[ Key.v check ; Key.v verify_sha256 ; Key.v remote ;
Key.v parallel_downloads ; Key.v hook_url ; Key.v tls_authenticator ;
Key.v port ; Key.v sectors_cache ; Key.v sectors_git ;
Key.v ignore_local_git ;

View file

@ -276,7 +276,7 @@ module Make
read_more a 0
(* on disk, we use a flat file system where the filename is the sha256 of the data *)
let init ~verify dev dev_md5s dev_sha512s =
let init ~verify_sha256 dev dev_md5s dev_sha512s =
KV.list dev Mirage_kv.Key.empty >>= function
| Error e -> Logs.err (fun m -> m "error %a listing kv" KV.pp_error e); assert false
| Ok entries ->
@ -284,14 +284,14 @@ module Make
Cache.read t.dev_md5s >>= fun r ->
(match r with
| Ok Some s ->
if not verify then
if not verify_sha256 then
Result.iter (fun md5s -> t.md5s <- md5s) (unmarshal_sm s)
| Ok None -> Logs.debug (fun m -> m "No md5s cached")
| Error e -> Logs.warn (fun m -> m "Error reading md5s cache: %a" Cache.pp_error e));
Cache.read t.dev_sha512s >>= fun r ->
(match r with
| Ok Some s ->
if not verify then
if not verify_sha256 then
Result.iter (fun sha512s -> t.sha512s <- sha512s) (unmarshal_sm s)
| Ok None -> Logs.debug (fun m -> m "No sha512s cached")
| Error e -> Logs.warn (fun m -> m "Error reading sha512s cache: %a" Cache.pp_error e));
@ -307,7 +307,7 @@ module Make
| `Value ->
let open Mirage_crypto.Hash in
let sha256_final =
if verify then
if verify_sha256 then
let f s =
let digest = SHA256.get s in
if not (String.equal name (to_hex digest)) then
@ -771,7 +771,7 @@ stamp: %S
Cache.connect sha512s >>= fun sha512s ->
Cache.connect git_dump >>= fun git_dump ->
Logs.info (fun m -> m "Available bytes in tar storage: %Ld" (KV.free kv));
Disk.init ~verify:(Key_gen.verify ()) kv md5s sha512s >>= fun disk ->
Disk.init ~verify_sha256:(Key_gen.verify_sha256 ()) kv md5s sha512s >>= fun disk ->
if Key_gen.check () then
Lwt.return_unit
else