Skip to content

Commit 13f37b6

Browse files
committed
fix(task): treat all open errors as NotFound
1 parent 37dfa63 commit 13f37b6

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

crates/vite_task/src/error.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use std::{ffi::OsString, io, path::Path, sync::Arc};
1+
use std::{ffi::OsString, io, path::Path};
22

33
use fspy::error::SpawnError;
44
use petgraph::algo::Cycle;
55
use vite_path::{
6-
AbsolutePath, RelativePathBuf,
6+
RelativePathBuf,
77
absolute::StripPrefixError,
88
relative::{FromPathError, InvalidPathDataError},
99
};
@@ -54,9 +54,6 @@ pub enum Error {
5454
#[error("The path ({path:?}) is not a valid relative path because: {reason}")]
5555
InvalidRelativePath { path: Box<Path>, reason: FromPathError },
5656

57-
#[error("IO error: {err} at {path:?}")]
58-
IoWithPath { err: io::Error, path: Arc<AbsolutePath> },
59-
6057
#[cfg(unix)]
6158
#[error("Unsupported file type: {0:?}")]
6259
UnsupportedFileType(nix::dir::Type),

crates/vite_task/src/fs.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ impl FileSystem for RealFileSystem {
4949

5050
let file = match File::open(std_path) {
5151
Ok(file) => file,
52+
#[allow(unused)]
5253
Err(err) => {
5354
// On Windows, File::open fails specifically for directories with PermissionDenied
5455
#[cfg(windows)]
@@ -59,17 +60,9 @@ impl FileSystem for RealFileSystem {
5960
}
6061
}
6162

62-
return if matches!(
63-
err.kind(),
64-
io::ErrorKind::NotFound |
65-
// A component used as a directory in path is not a directory,
66-
// e.g. "/foo.txt/bar" where "/foo.txt" is a file
67-
io::ErrorKind::NotADirectory
68-
) {
69-
Ok(PathFingerprint::NotFound)
70-
} else {
71-
Err(Error::IoWithPath { err, path: path.clone() })
72-
};
63+
// There are many reasons why opening a file might fail (NotFound, InvalidFilename, NotADirectory, PermissionDenied).
64+
// Consider all of them as NotFound for fingerprinting purposes.
65+
return Ok(PathFingerprint::NotFound);
7366
}
7467
};
7568

0 commit comments

Comments
 (0)