Skip to content

Commit

Permalink
lib: Evaluate {QemuNBD,Nbdkit}.is_installed only once
Browse files Browse the repository at this point in the history
Using a lazy suspension we can make sure these are evaluated only once
per run.
  • Loading branch information
rwmjones committed Nov 23, 2021
1 parent ab55f94 commit f34865c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/nbdkit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ open Unix_utils

open Utils

let is_installed () =
Sys.command "nbdkit --version >/dev/null 2>&1" = 0
let is_installed =
let test = lazy (Sys.command "nbdkit --version >/dev/null 2>&1" = 0) in
fun () -> Lazy.force test

type config = (string * string) list

Expand Down
5 changes: 3 additions & 2 deletions lib/qemuNBD.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ open Unix_utils

open Utils

let is_installed () =
Sys.command "qemu-nbd --version >/dev/null 2>&1" = 0
let is_installed =
let test = lazy (Sys.command "qemu-nbd --version >/dev/null 2>&1" = 0) in
fun () -> Lazy.force test

type version = int * int * int

Expand Down

0 comments on commit f34865c

Please sign in to comment.