Improve logging of bad checksums #7

Merged
reynir merged 1 commit from log-bad-checksum into main 2024-10-17 16:12:31 +00:00
2 changed files with 9 additions and 2 deletions
Showing only changes of commit 5938a60289 - Show all commits

View file

@ -62,3 +62,8 @@ let digests_to_hm digests =
Digestif.SHA256.(to_raw_string (get digests.sha256)) Digestif.SHA256.(to_raw_string (get digests.sha256))
|> HM.add `SHA512 |> HM.add `SHA512
Digestif.SHA512.(to_raw_string (get digests.sha512)) Digestif.SHA512.(to_raw_string (get digests.sha512))
let get digests = function
| `MD5 -> Digestif.MD5.(to_raw_string (get digests.md5))
| `SHA256 -> Digestif.SHA256.(to_raw_string (get digests.sha256))
| `SHA512 -> Digestif.SHA512.(to_raw_string (get digests.sha512))

View file

@ -480,8 +480,10 @@ module Make
Logs.err (fun m -> m "Write failure for %s: %a" url KV.pp_write_error e) Logs.err (fun m -> m "Write failure for %s: %a" url KV.pp_write_error e)
else begin else begin
(if sizes_match then (if sizes_match then
Logs.err (fun m -> m "Bad checksum %s: computed %s expected %s" url Logs.err (fun m -> m "Bad checksum %s:%s: computed %s expected %s" url
(hash_to_string hash) (Ohex.encode csum)) (hash_to_string hash)
(Archive_checksum.get digests hash)
(Ohex.encode csum))
else match body with else match body with
| `Fixed_body (reported, actual) -> | `Fixed_body (reported, actual) ->
Logs.err (fun m -> m "Size mismatch %s: received %a bytes expected %Lu bytes" Logs.err (fun m -> m "Size mismatch %s: received %a bytes expected %Lu bytes"