File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed
Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -247,11 +247,9 @@ impl<Fs: FileSystem> Cache<Fs> {
247247 visited : & mut StdHashSet < u64 , BuildHasherDefault < IdentityHasher > > ,
248248 ) -> Result < CachedPath , ResolveError > {
249249 // Check cache first - if this path was already canonicalized, return the cached result
250- if let Some ( cached) = path. canonicalized . get ( ) {
251- return cached. as_ref ( ) . map_err ( Clone :: clone) . and_then ( |weak| {
252- weak. upgrade ( ) . map ( CachedPath ) . ok_or_else ( || {
253- io:: Error :: new ( io:: ErrorKind :: NotFound , "Cached path no longer exists" ) . into ( )
254- } )
250+ if let Some ( weak) = path. canonicalized . get ( ) {
251+ return weak. upgrade ( ) . map ( CachedPath ) . ok_or_else ( || {
252+ io:: Error :: new ( io:: ErrorKind :: NotFound , "Cached path no longer exists" ) . into ( )
255253 } ) ;
256254 }
257255
@@ -292,15 +290,14 @@ impl<Fs: FileSystem> Cache<Fs> {
292290 Ok ( normalized)
293291 } )
294292 } ,
295- ) ;
293+ ) ? ;
296294
297295 // Cache the result before removing from visited set
298296 // This ensures parent canonicalization results are cached and reused
299- path. canonicalized
300- . get_or_init ( || res. as_ref ( ) . map ( |cp| Arc :: downgrade ( & cp. 0 ) ) . map_err ( Clone :: clone) ) ;
297+ let _ = path. canonicalized . set ( Arc :: downgrade ( & res. 0 ) ) ;
301298
302299 // Remove from visited set when unwinding the recursion
303300 visited. remove ( & path. hash ) ;
304- res
301+ Ok ( res)
305302 }
306303}
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ pub struct CachedPathImpl {
2727 pub is_node_modules : bool ,
2828 pub inside_node_modules : bool ,
2929 pub meta : OnceLock < Option < FileMetadata > > ,
30- pub canonicalized : OnceLock < Result < Weak < CachedPathImpl > , ResolveError > > ,
30+ pub canonicalized : OnceLock < Weak < CachedPathImpl > > ,
3131 pub node_modules : OnceLock < Option < Weak < CachedPathImpl > > > ,
3232 pub package_json : OnceLock < Option < Arc < PackageJson > > > ,
3333 pub tsconfig : OnceLock < Option < Arc < TsConfig > > > ,
You can’t perform that action at this time.
0 commit comments