• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MinaProtocol / mina / 1442

11 Jun 2026 08:45AM UTC coverage: 33.298% (-4.9%) from 38.236%
1442

push

buildkite

web-flow
Merge pull request #18926 from MinaProtocol/dkijania/remove-rosetta-artifact

Buildkite: remove Rosetta artifact variant (build rosetta from apps-only + config)

25141 of 75503 relevant lines covered (33.3%)

16634.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

74.29
/src/lib/key_cache/sync/key_cache_sync.ml
1
open Core
2
open Key_cache
3
include T (Or_error)
4

5
let on_disk to_string read write prefix =
6
  let path k = prefix ^/ to_string k in
183✔
7
  let read k =
8
    let p = path k in
148✔
9
    match Sys.file_exists p with
148✔
10
    | `No | `Unknown ->
×
11
        Or_error.errorf "file %s does not exist or cannot be read" p
12
    | `Yes ->
2✔
13
        read k ~path:p
14
  in
15
  let write key v =
16
    match Sys.is_directory prefix with
35✔
17
    | `No | `Unknown ->
×
18
        Or_error.errorf "directory %s does not exist or cannot be read" prefix
19
    | `Yes ->
35✔
20
        write key v (path key)
35✔
21
  in
22
  { read; write }
23

24
module Disk_storable = struct
25
  include Disk_storable (Or_error)
26

27
  let of_binable to_string m =
28
    (* TODO: Make more efficient *)
29
    let read _ ~path =
×
30
      Or_error.try_with (fun () ->
×
31
          Binable.of_string m (In_channel.read_all path) )
×
32
    in
33
    let write _k t path =
34
      Or_error.try_with (fun () ->
×
35
          Out_channel.write_all path ~data:(Binable.to_string m t) )
×
36
    in
37
    { to_string; read; write }
38

39
  let simple to_string read write =
40
    { to_string
19✔
41
    ; read = (fun k ~path -> read k ~path)
×
42
    ; write = (fun k v s -> write k v s)
19✔
43
    }
44
end
45

46
let read spec { Disk_storable.to_string; read = r; write = w } k =
47
  Or_error.find_map_ok spec ~f:(fun s ->
37✔
48
      let res, cache_hit =
185✔
49
        match s with
50
        | Spec.On_disk { directory; should_write } ->
148✔
51
            ( (on_disk to_string r w directory).read k
148✔
52
            , if should_write then `Locally_generated else `Cache_hit )
37✔
53
        | S3 _ ->
37✔
54
            (Or_error.errorf "Downloading from S3 is disabled", `Cache_hit)
37✔
55
      in
56
      let%map.Or_error res = res in
57
      (res, cache_hit) )
×
58

59
let write spec { Disk_storable.to_string; read = r; write = w } k v =
60
  let errs =
35✔
61
    List.filter_map spec ~f:(fun s ->
62
        let res =
156✔
63
          match s with
64
          | Spec.On_disk { directory; should_write } ->
140✔
65
              if should_write then (
35✔
66
                Unix.mkdir_p directory ;
67
                (on_disk to_string r w directory).write k v )
35✔
68
              else Or_error.return ()
105✔
69
          | S3 { bucket_prefix = _; install_path = _ } ->
16✔
70
              Or_error.return ()
16✔
71
        in
72
        match res with Error e -> Some e | Ok () -> None )
19✔
73
  in
74
  match errs with [] -> Ok () | errs -> Error (Error.of_list errs)
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc