From e3688e207e2227a40ef692f12c25b4e450b9aa4f Mon Sep 17 00:00:00 2001 From: Bryan Bennett Date: Fri, 22 Dec 2023 08:37:32 -0500 Subject: [PATCH] Catch error thrown by lstat if path does not exist --- src/flake_env.re | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/flake_env.re b/src/flake_env.re index eb06a88..696d87f 100644 --- a/src/flake_env.re +++ b/src/flake_env.re @@ -131,6 +131,7 @@ let get_watches = () => { // TODO: Maybe make this more terse? let rec rmrf = (path) => { switch (Unix.lstat(path).st_kind) { + | exception Unix.Unix_error(_, _, _) => () | S_REG => Unix.unlink(path) | S_LNK => Unix.unlink(path) | S_DIR => { @@ -174,6 +175,7 @@ let freshen_cache = (layout_dir, hash, flake_specifier) => { switch (exit_code) { | Ok() => { Out_channel.with_file(~f=f=> Out_channel.output_string(f, stdout_content), profile_rc); + // TODO: flake inputs! switch (nix(["build", "--out-link", profile, tmp_profile])) { | (Ok(), _) => { Sys_unix.remove(tmp_profile); @@ -223,13 +225,13 @@ let main = () => { } }; | Error(e) => { - Printf.eprintf("%s", e); + Printf.eprintf("%s\n", e); exit(1); } } } | Error(e) => { - Printf.eprintf("%s", e); + Printf.eprintf("%s\n", e); exit(1); } };