diff --git a/mirage/unikernel.ml b/mirage/unikernel.ml index 29f0cd9..415024b 100644 --- a/mirage/unikernel.ml +++ b/mirage/unikernel.ml @@ -194,33 +194,32 @@ module Make let pp_failed ppf = function | `Write_error e -> - Fmt.pf ppf "write error: %a" KV.pp_write_error e + KV.pp_write_error ppf e | `Swap e -> - Fmt.pf ppf "swap error: %a" Swap.pp_error e + Swap.pp_error ppf e | `Bad_checksum (hash, computed, expected) -> Fmt.pf ppf "%s checksum: computed %s expected %s" (hash_to_string hash) (Ohex.encode computed) (Ohex.encode expected) | `Bad_response (status, reason) -> - Fmt.pf ppf "bad response: %a %s" H2.Status.pp_hum status reason + Fmt.pf ppf "%a %s" H2.Status.pp_hum status reason | `Mimic me -> - Fmt.pf ppf "mimic: %a" Mimic.pp_error me + Mimic.pp_error ppf me - let compare_failed a b = match a, b with - | `Write_error _, `Write_error _ -> 0 - | `Write_error _, _ -> 1 - | _, `Write_error _ -> -1 - | `Swap _, `Swap _ -> 0 - | `Swap _, _ -> 1 - | _, `Swap _ -> -1 - | `Bad_checksum _, `Bad_checksum _ -> 0 - | `Bad_checksum _, _ -> 1 - | _, `Bad_checksum _ -> -1 - | `Bad_response _, `Bad_response _ -> 0 - | `Bad_response _, _ -> 1 - | _, `Bad_response _ -> -1 - | `Mimic _, `Mimic _ -> 0 + let key_of_failed = function + | `Write_error _ -> `Write_error + | `Swap _ -> `Swap + | `Bad_checksum _ -> `Bad_checksum + | `Bad_response _ -> `Bad_response + | `Mimic _ -> `Mimic + + let pp_key ppf = function + | `Write_error -> Fmt.pf ppf "Write error" + | `Swap -> Fmt.pf ppf "Swap error" + | `Bad_checksum -> Fmt.pf ppf "Bad checksum" + | `Bad_response -> Fmt.pf ppf "Bad response" + | `Mimic -> Fmt.pf ppf "Mimic" module Disk = struct type t = { @@ -677,14 +676,15 @@ stamp: %S t.index <- index; Some (changes, urls)) - let status disk = + let status t disk = (* report status: - archive size (can we easily measure?) and number of "good" elements - list of current downloads - list of failed downloads *) let archive_stats = - Fmt.str "" + Fmt.str "" + t.commit_id t.modified t.repo (SM.cardinal disk.Disk.md5s) (KV.free disk.Disk.dev) in @@ -699,18 +699,37 @@ stamp: %S in header ^ String.concat "" content ^ "" and failed_downloads = - let header = "

Failed downloads

" + header ^ String.concat "" content and parse_errors = let header = "

Parse errors