Skip to content

Commit a925506

Browse files
CopilotBrooooooklyn
andcommitted
Fix merge conflicts: Update filesystem tests to use vite_path types after main merge
Co-authored-by: Brooooooklyn <3468483+Brooooooklyn@users.noreply.github.com>
1 parent 2482a77 commit a925506

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

  • crates/vite_task/src

crates/vite_task/src/fs.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
use std::{
2-
ffi::OsStr,
32
fs::File,
43
hash::Hasher as _,
54
io::{self, Read},
6-
path::PathBuf,
75
sync::Arc,
86
};
97

108
use crate::Error;
119
use crate::{execute::PathRead, fingerprint::PathFingerprint};
1210
use dashmap::DashMap;
1311
use std::io::BufRead;
14-
#[cfg(unix)]
15-
use vite_path::AbsolutePath;
12+
use vite_path::{AbsolutePath, AbsolutePathBuf};
1613
use vite_str::Str;
1714

1815
use crate::collections::HashMap;
@@ -208,7 +205,7 @@ impl FileSystem for RealFileSystem {
208205
pub struct CachedFileSystem<FS = RealFileSystem> {
209206
underlying: FS,
210207
#[expect(dead_code)]
211-
cache: DashMap<Arc<OsStr>, PathFingerprint>,
208+
cache: DashMap<AbsolutePathBuf, PathFingerprint>,
212209
}
213210

214211
impl<FS: FileSystem> FileSystem for CachedFileSystem<FS> {
@@ -239,8 +236,8 @@ impl<FS: FileSystem> FileSystem for CachedFileSystem<FS> {
239236

240237
impl<FS> CachedFileSystem<FS> {
241238
#[expect(dead_code)]
242-
pub fn invalidate_path(&self, path: &OsStr) {
243-
self.cache.remove(path);
239+
pub fn invalidate_path(&self, path: &AbsolutePath) {
240+
self.cache.remove(&path.to_absolute_path_buf());
244241
}
245242
}
246243

@@ -254,7 +251,8 @@ mod tests {
254251
#[test]
255252
fn test_fingerprint_nonexistent_file() {
256253
let fs = RealFileSystem::default();
257-
let nonexistent_path = Arc::<OsStr>::from(std::ffi::OsString::from("/nonexistent/path"));
254+
let nonexistent_path =
255+
Arc::<AbsolutePath>::from(AbsolutePathBuf::new("/nonexistent/path".into()).unwrap());
258256
let path_read = PathRead { read_dir_entries: false };
259257

260258
let result = fs.fingerprint_path(&nonexistent_path, path_read).unwrap();
@@ -270,7 +268,8 @@ mod tests {
270268
// Create a test file with known content
271269
std::fs::write(&temp_file, "Hello, World!").unwrap();
272270

273-
let file_path = Arc::<OsStr>::from(temp_file.as_os_str().to_os_string());
271+
let file_path =
272+
Arc::<AbsolutePath>::from(AbsolutePathBuf::new(temp_file.to_path_buf()).unwrap());
274273
let path_read = PathRead { read_dir_entries: false };
275274

276275
let result = fs.fingerprint_path(&file_path, path_read).unwrap();
@@ -290,7 +289,8 @@ mod tests {
290289
std::fs::write(temp_dir.path().join("file1.txt"), "content1").unwrap();
291290
std::fs::write(temp_dir.path().join("file2.txt"), "content2").unwrap();
292291

293-
let dir_path = Arc::<OsStr>::from(temp_dir.path().as_os_str().to_os_string());
292+
let dir_path =
293+
Arc::<AbsolutePath>::from(AbsolutePathBuf::new(temp_dir.path().to_path_buf()).unwrap());
294294
let path_read = PathRead { read_dir_entries: true };
295295

296296
let result = match fs.fingerprint_path(&dir_path, path_read) {
@@ -341,7 +341,8 @@ mod tests {
341341

342342
std::fs::write(&temp_file, "consistent content").unwrap();
343343

344-
let file_path = Arc::<OsStr>::from(temp_file.as_os_str().to_os_string());
344+
let file_path =
345+
Arc::<AbsolutePath>::from(AbsolutePathBuf::new(temp_file.to_path_buf()).unwrap());
345346
let path_read = PathRead { read_dir_entries: false };
346347

347348
// Get multiple fingerprints

0 commit comments

Comments
 (0)