diff --git a/builder-web.opam b/builder-web.opam index ba789f8..466827a 100644 --- a/builder-web.opam +++ b/builder-web.opam @@ -14,6 +14,8 @@ build: [ depends: [ "builder" "opium" + "bos" + "hex" ] synopsis: "Web interface for builder" diff --git a/lib/builder_web.ml b/lib/builder_web.ml index 75e268e..4a15f32 100644 --- a/lib/builder_web.ml +++ b/lib/builder_web.ml @@ -92,7 +92,7 @@ let routes (t : Model.t) = let body = Body.of_string data in Response.make ~body () |> Response.add_header ("Content-type", Magic_mime.lookup file) - |> Response.set_etag (Base64.encode_string digest.sha256) + |> Response.set_etag (Base64.encode_string (Cstruct.to_string digest.sha256)) in [ diff --git a/lib/dune b/lib/dune index ff590ef..7a51a79 100644 --- a/lib/dune +++ b/lib/dune @@ -1,3 +1,3 @@ (library (name builder_web) - (libraries builder opium tyxml bos rresult duration)) + (libraries builder opium tyxml bos rresult duration hex)) diff --git a/lib/model.ml b/lib/model.ml index c422c28..529279e 100644 --- a/lib/model.ml +++ b/lib/model.ml @@ -25,8 +25,7 @@ type job_run_info = { } type digest = { - sha256 : string; - sha512 : string; + sha256 : Cstruct.t; } type t = { @@ -59,8 +58,7 @@ let digest (path, data) = let module H = Mirage_crypto.Hash in let data = Cstruct.of_string data in (path, { - sha256 = H.SHA256.digest data |> Cstruct.to_string; - sha512 = H.SHA512.digest data |> Cstruct.to_string; + sha256 = H.SHA256.digest data; }) let read_full_with_digests t path run = diff --git a/lib/model.mli b/lib/model.mli index 8058aa5..4e69fab 100644 --- a/lib/model.mli +++ b/lib/model.mli @@ -9,8 +9,7 @@ type job_run_meta = { } type digest = { - sha256 : string; - sha512 : string; + sha256 : Cstruct.t; } type job_run_info = { diff --git a/lib/views.ml b/lib/views.ml index cc49e49..d64fcdf 100644 --- a/lib/views.ml +++ b/lib/views.ml @@ -129,17 +129,14 @@ let job_run p [txtf "Execution result: %a." Builder.pp_execution_result result]; h3 [txt "Digests of build artifacts"]; dl (List.concat_map - (fun (path, { Model.sha256; sha512 }) -> [ + (fun (path, { Model.sha256 }) -> + let (`Hex sha256_hex) = Hex.of_cstruct sha256 in + [ dt [a ~a:[Fmt.kstr a_href "f/%a" Fpath.pp path] [code [txtf "%a" Fpath.pp path]]; txt "(SHA256)"]; - dd [code [txtf "%s" (Base64.encode_string sha256)]]; - dt [a - ~a:[Fmt.kstr a_href "f/%a" Fpath.pp path] - [code [txtf "%a" Fpath.pp path]]; - txt "(SHA512)"]; - dd [code [txtf "%s" (Base64.encode_string sha512)]]; + dd [code [txt sha256_hex]]; ]) digests); h3 [txt "Job script"];