Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions crates/vite_task/src/error.rs
Original file line number Diff line number Diff line change
@@ -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},
};
Expand Down Expand Up @@ -54,9 +54,6 @@ pub enum Error {
#[error("The path ({path:?}) is not a valid relative path because: {reason}")]
InvalidRelativePath { path: Box<Path>, reason: FromPathError },

#[error("IO error: {err} at {path:?}")]
IoWithPath { err: io::Error, path: Arc<AbsolutePath> },

#[cfg(unix)]
#[error("Unsupported file type: {0:?}")]
UnsupportedFileType(nix::dir::Type),
Expand Down
15 changes: 4 additions & 11 deletions crates/vite_task/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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)]
Expand All @@ -59,17 +60,9 @@ impl FileSystem for RealFileSystem {
}
}

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() })
};
// There are many reasons why opening a file might fail (NotFound, InvalidFilename, NotADirectory, PermissionDenied).
Comment thread
fengmk2 marked this conversation as resolved.
// Consider all of them as NotFound for fingerprinting purposes.
return Ok(PathFingerprint::NotFound);
}
};

Expand Down