Skip to content

Commit

Permalink
WIP: fix: dune_digest: don't open with Unix module
Browse files Browse the repository at this point in the history
  • Loading branch information
emillon committed Jul 24, 2023
1 parent cb3489d commit e3754f1
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/dune_digest/dune_digest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ end

module Direct_impl : Digest_impl = struct
let file file =
let fd =
match Unix.openfile file [ Unix.O_RDONLY ] 0 with
| fd -> fd
| exception Unix.Unix_error (Unix.EACCES, _, _) ->
raise (Sys_error (sprintf "%s: Permission denied" file))
| exception exn -> reraise exn
in
Exn.protectx fd ~f:md5_fd ~finally:Unix.close
let ic = Stdlib.open_in_bin file in
Exn.protect
~f:(fun () ->
let fd = Unix.descr_of_in_channel ic in
md5_fd fd)
~finally:(fun () -> Stdlib.close_in_noerr ic)

let string = D.string
end
Expand Down

0 comments on commit e3754f1

Please sign in to comment.