From 68bba48d592c0b30b617642cbe5b1cda758b0272 Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Sat, 20 Jan 2024 21:11:29 +0100 Subject: feat(tvix/castore): `process_entry` cannot process unsupported nodes In the past, we had a `todo!` on unsupported node types, this returns a proper error that can be caught by the caller. Change-Id: Icba4c1dab33c0d670a97f162c9b358d1ed5855cb Reviewed-on: https://cl.tvl.fyi/c/depot/+/10675 Tested-by: BuildkiteCI Reviewed-by: flokli --- tvix/castore/src/import.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tvix') diff --git a/tvix/castore/src/import.rs b/tvix/castore/src/import.rs index 1c99df480d14..f7677e63142d 100644 --- a/tvix/castore/src/import.rs +++ b/tvix/castore/src/import.rs @@ -10,7 +10,11 @@ use crate::Error as CastoreError; use async_stream::stream; use futures::pin_mut; use futures::Stream; +use std::fs::FileType; + +#[cfg(target_family = "unix")] use std::os::unix::ffi::OsStrExt; + use std::{ collections::HashMap, fmt::Debug, @@ -41,6 +45,9 @@ pub enum Error { #[error("unable to read {0}: {1}")] UnableToRead(PathBuf, std::io::Error), + + #[error("unsupported file {0} type: {1:?}")] + UnsupportedFileType(PathBuf, FileType), } impl From for Error { @@ -145,7 +152,12 @@ where executable: metadata.permissions().mode() & 64 != 0, })); } - todo!("handle other types") + + // Nix says things like: error: file '/home/raito/dev/code.tvl.fyi/tvix/glue/src/tests/import_fixtures/a_devnode' has an unsupported type + Err(Error::UnsupportedFileType( + entry.path().to_path_buf(), + file_type, + )) } /// Walk the filesystem at a given path and returns a level-keyed list of directory entries. -- cgit 1.4.1