mirror of
https://git.sr.ht/~bryan_bennett/flake_env
synced 2025-12-16 14:41:24 +01:00
Catch error thrown by lstat if path does not exist
This commit is contained in:
parent
7ec4cfb172
commit
e3688e207e
1 changed files with 4 additions and 2 deletions
|
|
@ -131,6 +131,7 @@ let get_watches = () => {
|
||||||
// TODO: Maybe make this more terse?
|
// TODO: Maybe make this more terse?
|
||||||
let rec rmrf = (path) => {
|
let rec rmrf = (path) => {
|
||||||
switch (Unix.lstat(path).st_kind) {
|
switch (Unix.lstat(path).st_kind) {
|
||||||
|
| exception Unix.Unix_error(_, _, _) => ()
|
||||||
| S_REG => Unix.unlink(path)
|
| S_REG => Unix.unlink(path)
|
||||||
| S_LNK => Unix.unlink(path)
|
| S_LNK => Unix.unlink(path)
|
||||||
| S_DIR => {
|
| S_DIR => {
|
||||||
|
|
@ -174,6 +175,7 @@ let freshen_cache = (layout_dir, hash, flake_specifier) => {
|
||||||
switch (exit_code) {
|
switch (exit_code) {
|
||||||
| Ok() => {
|
| Ok() => {
|
||||||
Out_channel.with_file(~f=f=> Out_channel.output_string(f, stdout_content), profile_rc);
|
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])) {
|
switch (nix(["build", "--out-link", profile, tmp_profile])) {
|
||||||
| (Ok(), _) => {
|
| (Ok(), _) => {
|
||||||
Sys_unix.remove(tmp_profile);
|
Sys_unix.remove(tmp_profile);
|
||||||
|
|
@ -223,13 +225,13 @@ let main = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
| Error(e) => {
|
| Error(e) => {
|
||||||
Printf.eprintf("%s", e);
|
Printf.eprintf("%s\n", e);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| Error(e) => {
|
| Error(e) => {
|
||||||
Printf.eprintf("%s", e);
|
Printf.eprintf("%s\n", e);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue