Skip to content

Commit

Permalink
[Artifact_substitution] Wrap some channel opening into a fiber
Browse files Browse the repository at this point in the history
     So that opening and closing be evaluated directly

Signed-off-by: François Bobot <francois.bobot@cea.fr>
  • Loading branch information
bobot committed Jun 9, 2021
1 parent 7f5eb7a commit 4f2ac8f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dune_rules/artifact_substitution.ml
Original file line number Diff line number Diff line change
Expand Up @@ -558,15 +558,17 @@ let copy ~conf ~input_file ~input ~output =
parse ~input ~mode:(Copy { conf; input_file; output })

let copy_file ~conf ?chmod ~src ~dst () =
let ic, oc = Io.setup_copy ?chmod ~src ~dst () in
let open Fiber.O in
let* ic, oc = Fiber.return (Io.setup_copy ?chmod ~src ~dst ()) in
Fiber.finalize
~finally:(fun () ->
Io.close_both (ic, oc);
Fiber.return ())
(fun () -> copy ~conf ~input_file:src ~input:(input ic) ~output:(output oc))

let test_file ~src () =
let ic = Io.open_in src in
let open Fiber.O in
let* ic = Fiber.return (Io.open_in src) in
Fiber.finalize
~finally:(fun b ->
Io.close_in ic;
Expand Down

0 comments on commit 4f2ac8f

Please sign in to comment.