diff --git a/crates/vite_task/src/error.rs b/crates/vite_task/src/error.rs index 1aba67eb..7ea49bcd 100644 --- a/crates/vite_task/src/error.rs +++ b/crates/vite_task/src/error.rs @@ -1,9 +1,9 @@ -use std::{ffi::OsString, io, path::Path, sync::Arc}; +use std::{ffi::OsString, io, path::Path}; use fspy::error::SpawnError; use petgraph::algo::Cycle; use vite_path::{ - AbsolutePath, RelativePathBuf, + RelativePathBuf, absolute::StripPrefixError, relative::{FromPathError, InvalidPathDataError}, }; @@ -54,9 +54,6 @@ pub enum Error { #[error("The path ({path:?}) is not a valid relative path because: {reason}")] InvalidRelativePath { path: Box, reason: FromPathError }, - #[error("IO error: {err} at {path:?}")] - IoWithPath { err: io::Error, path: Arc }, - #[cfg(unix)] #[error("Unsupported file type: {0:?}")] UnsupportedFileType(nix::dir::Type), diff --git a/crates/vite_task/src/fs.rs b/crates/vite_task/src/fs.rs index e332a520..b47ba81a 100644 --- a/crates/vite_task/src/fs.rs +++ b/crates/vite_task/src/fs.rs @@ -40,6 +40,7 @@ fn hash_content(mut stream: impl Read) -> io::Result { } impl FileSystem for RealFileSystem { + #[tracing::instrument(level = "trace")] fn fingerprint_path( &self, path: &Arc, @@ -49,6 +50,7 @@ impl FileSystem for RealFileSystem { let file = match File::open(std_path) { Ok(file) => file, + #[allow(unused)] Err(err) => { // On Windows, File::open fails specifically for directories with PermissionDenied #[cfg(windows)] @@ -58,18 +60,16 @@ impl FileSystem for RealFileSystem { return RealFileSystem::process_directory(std_path, path_read); } } - - return if matches!( - err.kind(), - io::ErrorKind::NotFound | - // A component used as a directory in path is not a directory, - // e.g. "/foo.txt/bar" where "/foo.txt" is a file - io::ErrorKind::NotADirectory - ) { - Ok(PathFingerprint::NotFound) - } else { - Err(Error::IoWithPath { err, path: path.clone() }) - }; + if err.kind() != io::ErrorKind::NotFound { + tracing::trace!( + "Uncommon error when opening {:?} for fingerprinting: {}", + std_path, + err + ); + } + // There are many reasons why opening a file might fail (NotFound, InvalidFilename, NotADirectory, PermissionDenied). + // Consider all of them as NotFound for fingerprinting purposes. + return Ok(PathFingerprint::NotFound); } };