@@ -28,13 +28,9 @@ use std::{
28
28
borrow:: Cow ,
29
29
cmp:: min,
30
30
collections:: HashSet ,
31
- fmt:: {
32
- Debug , Display , Formatter , Write as _, { self } ,
33
- } ,
31
+ fmt:: { self , Debug , Display , Formatter , Write as _} ,
34
32
fs:: FileType ,
35
- io:: {
36
- BufRead , ErrorKind , { self } ,
37
- } ,
33
+ io:: { self , BufRead , ErrorKind } ,
38
34
mem:: take,
39
35
path:: { Path , PathBuf , MAIN_SEPARATOR } ,
40
36
sync:: Arc ,
@@ -62,8 +58,8 @@ use tokio::{
62
58
} ;
63
59
use tracing:: Instrument ;
64
60
use turbo_tasks:: {
65
- mark_session_dependent, trace:: TraceRawVcs , Completion , Invalidator , RcStr , ReadRef ,
66
- ResolvedVc , ValueToString , Vc ,
61
+ mark_session_dependent, mark_stateful , trace:: TraceRawVcs , Completion , Invalidator , RcStr ,
62
+ ReadRef , ResolvedVc , ValueToString , Vc ,
67
63
} ;
68
64
use turbo_tasks_hash:: {
69
65
hash_xxh3_hash128, hash_xxh3_hash64, DeterministicHash , DeterministicHasher ,
@@ -207,8 +203,10 @@ pub struct DiskFileSystem {
207
203
#[ serde( skip) ]
208
204
mutex_map : MutexMap < PathBuf > ,
209
205
#[ turbo_tasks( debug_ignore, trace_ignore) ]
206
+ #[ serde( skip) ]
210
207
invalidator_map : Arc < InvalidatorMap > ,
211
208
#[ turbo_tasks( debug_ignore, trace_ignore) ]
209
+ #[ serde( skip) ]
212
210
dir_invalidator_map : Arc < InvalidatorMap > ,
213
211
/// Lock that makes invalidation atomic. It will keep a write lock during
214
212
/// watcher invalidation and a read lock during other operations.
@@ -309,27 +307,37 @@ impl DiskFileSystem {
309
307
} ) ;
310
308
}
311
309
312
- pub fn start_watching ( & self , poll_interval : Option < Duration > ) -> Result < ( ) > {
313
- self . start_watching_internal ( false , poll_interval)
310
+ pub async fn start_watching ( & self , poll_interval : Option < Duration > ) -> Result < ( ) > {
311
+ self . start_watching_internal ( false , poll_interval) . await
314
312
}
315
313
316
- pub fn start_watching_with_invalidation_reason (
314
+ pub async fn start_watching_with_invalidation_reason (
317
315
& self ,
318
316
poll_interval : Option < Duration > ,
319
317
) -> Result < ( ) > {
320
- self . start_watching_internal ( true , poll_interval)
318
+ self . start_watching_internal ( true , poll_interval) . await
321
319
}
322
320
323
- fn start_watching_internal (
321
+ #[ tracing:: instrument( level = "info" , name = "start filesystem watching" , skip_all, fields( path = %self . root) ) ]
322
+ async fn start_watching_internal (
324
323
& self ,
325
324
report_invalidation_reason : bool ,
326
325
poll_interval : Option < Duration > ,
327
326
) -> Result < ( ) > {
328
- let _span = tracing:: info_span!( "start filesystem watching" , path = & * self . root) . entered ( ) ;
329
327
let invalidator_map = self . invalidator_map . clone ( ) ;
330
328
let dir_invalidator_map = self . dir_invalidator_map . clone ( ) ;
331
329
let root_path = self . root_path ( ) . to_path_buf ( ) ;
332
330
331
+ // create the directory for the filesystem on disk, if it doesn't exist
332
+ retry_future ( || {
333
+ let path = root_path. as_path ( ) ;
334
+ fs:: create_dir_all ( & root_path) . instrument ( tracing:: info_span!(
335
+ "create root directory" ,
336
+ path = display( path. display( ) )
337
+ ) )
338
+ } )
339
+ . await ?;
340
+
333
341
let report_invalidation_reason =
334
342
report_invalidation_reason. then ( || ( self . name . clone ( ) , root_path. clone ( ) ) ) ;
335
343
let invalidation_lock = self . invalidation_lock . clone ( ) ;
@@ -419,9 +427,7 @@ impl DiskFileSystem {
419
427
/// ignore specific subpaths from each.
420
428
#[ turbo_tasks:: function]
421
429
pub async fn new ( name : RcStr , root : RcStr , ignored_subpaths : Vec < RcStr > ) -> Result < Vc < Self > > {
422
- mark_session_dependent ( ) ;
423
- // create the directory for the filesystem on disk, if it doesn't exist
424
- fs:: create_dir_all ( & root) . await ?;
430
+ mark_stateful ( ) ;
425
431
426
432
let instance = DiskFileSystem {
427
433
name,
0 commit comments