diff options
author | Matthew Tromp <matthewktromp@gmail.com> | 2024-07-27T19·48-0400 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-07-27T21·29+0000 |
commit | 0b987a509f189bb0b984c1b306a1b05e928b2296 (patch) | |
tree | 6c6eaa2598bdead7de97bf951116af6783e3c93f | |
parent | 4769d047b29f3fbad4767a858f4c0f202f2b33a9 (diff) |
fix(tvix/eval): don't bubble up io errors from path_exists r/8416
path_exists was returning an error when certain common IO errors were encountered. e.g. in the path "/dev/null/.", path_exists would throw an error because the underlying call to Path::try_exists threw an error because null isn't a directory. But if null isn't a directory, then the path is invalid, so this should really be returning false. That's what nix's behavior is and that's what makes sense. The trait function isn't being changed because some other implementers (e.g. tvix_store_io) have actual errors they can throw. Fixes: b/411 Change-Id: I9e810e7a198bffe61365697c6d3d7e71f264c20b Reviewed-on: https://cl.tvl.fyi/c/depot/+/12042 Tested-by: BuildkiteCI Autosubmit: chickadee <matthewktromp@gmail.com> Reviewed-by: aspen <root@gws.fyi>
-rw-r--r-- | tvix/eval/src/io.rs | 3 | ||||
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-path-exists-child-of-file.exp | 1 | ||||
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-path-exists-child-of-file.nix | 1 |
3 files changed, 4 insertions, 1 deletions
diff --git a/tvix/eval/src/io.rs b/tvix/eval/src/io.rs index 9acfd6eeba02..abe0e0518303 100644 --- a/tvix/eval/src/io.rs +++ b/tvix/eval/src/io.rs @@ -98,7 +98,8 @@ pub struct StdIO; #[cfg(feature = "impure")] impl EvalIO for StdIO { fn path_exists(&self, path: &Path) -> io::Result<bool> { - path.try_exists() + // In general, an IO error indicates the path doesn't exist + Ok(path.try_exists().unwrap_or(false)) } fn open(&self, path: &Path) -> io::Result<Box<dyn io::Read>> { diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-path-exists-child-of-file.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-path-exists-child-of-file.exp new file mode 100644 index 000000000000..c508d5366f70 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-path-exists-child-of-file.exp @@ -0,0 +1 @@ +false diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-path-exists-child-of-file.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-path-exists-child-of-file.nix new file mode 100644 index 000000000000..8588f0bddfc1 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-path-exists-child-of-file.nix @@ -0,0 +1 @@ +builtins.pathExists ("/dev/null/.") \ No newline at end of file |