@@ -279,7 +279,7 @@ pub struct RuntimeConfigFactory {
279279}
280280
281281impl RuntimeConfigFactory {
282- async fn build_config ( & self ) -> anyhow:: Result < watchexec :: config :: RuntimeConfig > {
282+ async fn build_config ( & self , rt : & watchexec :: Config ) -> anyhow:: Result < ( ) > {
283283 let manifest_str = tokio:: fs:: read_to_string ( & self . manifest_file ) . await ?;
284284 let manifest = spin_manifest:: manifest_from_str ( & manifest_str) ?;
285285 let filterer = self
@@ -289,12 +289,11 @@ impl RuntimeConfigFactory {
289289
290290 let handler = NotifyOnFileChange :: new ( self . notifier . clone ( ) , self . impact_description ) ;
291291
292- let mut rt = watchexec:: config:: RuntimeConfig :: default ( ) ;
293- rt. pathset ( [ & self . manifest_dir ] ) ;
292+ rt. pathset ( [ self . manifest_dir . as_path ( ) ] ) ;
294293 rt. filterer ( filterer) ;
295- rt. action_throttle ( self . debounce ) ;
296- rt. on_action ( handler) ;
297- Ok ( rt )
294+ rt. throttle ( self . debounce ) ;
295+ rt. on_action ( move |ah| handler. handle ( ah ) ) ;
296+ Ok ( ( ) )
298297 }
299298}
300299
@@ -320,13 +319,8 @@ impl NotifyOnFileChange {
320319 impact_description,
321320 }
322321 }
323- }
324322
325- impl watchexec:: handler:: Handler < watchexec:: action:: Action > for NotifyOnFileChange {
326- fn handle (
327- & mut self ,
328- action : watchexec:: action:: Action ,
329- ) -> std:: result:: Result < ( ) , Box < dyn std:: error:: Error > > {
323+ fn handle ( & self , action : watchexec:: action:: ActionHandler ) -> watchexec:: action:: ActionHandler {
330324 if self . despurifier . all_spurious ( & action) {
331325 tracing:: debug!( "spin watch ignored spurious changes: {}" , paths_of( & action) ) ;
332326 } else {
@@ -337,12 +331,12 @@ impl watchexec::handler::Handler<watchexec::action::Action> for NotifyOnFileChan
337331 ) ;
338332 _ = self . notifier . send ( Uuid :: new_v4 ( ) ) ;
339333 }
340- action . outcome ( watchexec :: action :: Outcome :: DoNothing ) ;
341- Ok :: < ( ) , Box < dyn std :: error :: Error + ' static > > ( ( ) )
334+
335+ action
342336 }
343337}
344338
345- fn paths_of ( action : & watchexec:: action:: Action ) -> String {
339+ fn paths_of ( action : & watchexec:: action:: ActionHandler ) -> String {
346340 action
347341 . events
348342 . iter ( )
@@ -353,13 +347,13 @@ fn paths_of(action: &watchexec::action::Action) -> String {
353347 . join ( ", " )
354348}
355349
356- fn path_of_event ( event : & watchexec :: event :: Event ) -> Option < & Path > {
350+ fn path_of_event ( event : & watchexec_events :: Event ) -> Option < & Path > {
357351 event. tags . iter ( ) . filter_map ( path_of_tag) . next ( )
358352}
359353
360- fn path_of_tag ( tag : & watchexec :: event :: Tag ) -> Option < & Path > {
354+ fn path_of_tag ( tag : & watchexec_events :: Tag ) -> Option < & Path > {
361355 match tag {
362- watchexec :: event :: Tag :: Path { path, .. } => Some ( path) ,
356+ watchexec_events :: Tag :: Path { path, .. } => Some ( path) ,
363357 _ => None ,
364358 }
365359}
@@ -369,7 +363,7 @@ mod despurifier {
369363 use std:: collections:: HashMap ;
370364 use std:: sync:: Mutex ;
371365 use std:: time:: SystemTime ;
372- use watchexec :: event :: { filekind:: FileEventKind , Tag } ;
366+ use watchexec_events :: { filekind:: FileEventKind , Tag } ;
373367
374368 pub struct Despurifier {
375369 process_start_time : SystemTime ,
@@ -384,13 +378,13 @@ mod despurifier {
384378 }
385379 }
386380
387- pub fn all_spurious ( & mut self , action : & watchexec:: action:: Action ) -> bool {
381+ pub fn all_spurious ( & self , action : & watchexec:: action:: ActionHandler ) -> bool {
388382 action. events . iter ( ) . all ( |e| self . all_spurious_evt ( e) )
389383 }
390384
391385 // This is necessary to check due to a bug on macOS emitting modify events on copies
392386 // https://github.com/rust-lang/rust/issues/107130
393- fn all_spurious_evt ( & mut self , event : & watchexec :: event :: Event ) -> bool {
387+ fn all_spurious_evt ( & self , event : & watchexec_events :: Event ) -> bool {
394388 // Deletions are never spurious
395389 if event
396390 . tags
@@ -438,7 +432,7 @@ mod despurifier {
438432 Self
439433 }
440434
441- pub fn all_spurious ( & mut self , _action : & watchexec:: action:: Action ) -> bool {
435+ pub fn all_spurious ( & self , _action : & watchexec:: action:: ActionHandler ) -> bool {
442436 false
443437 }
444438 }
@@ -459,8 +453,8 @@ impl ReconfigurableWatcher {
459453 async fn start (
460454 rtf : RuntimeConfigFactory ,
461455 ) -> anyhow:: Result < ( Self , tokio:: task:: JoinHandle < ( ) > ) > {
462- let rt = rtf . build_config ( ) . await ? ;
463- let watcher = Watchexec :: new ( watchexec :: config:: InitConfig :: default ( ) , rt ) ?;
456+ let watcher = Arc :: new ( Watchexec :: default ( ) ) ;
457+ rtf . build_config ( & watcher . config ) . await ?;
464458 let watcher_clone = watcher. clone ( ) ;
465459 let join_handle = tokio:: task:: spawn ( async move {
466460 _ = watcher_clone. main ( ) . await ;
@@ -477,16 +471,9 @@ impl ReconfigurableWatcher {
477471 pub async fn reconfigure ( & self ) {
478472 match self {
479473 Self :: Actual ( ( watchexec, rtf) ) => {
480- let rt = match rtf. build_config ( ) . await {
481- Ok ( rt) => rt,
482- Err ( e) => {
483- tracing:: error!( "Unable to re-configure watcher after manifest change. Changes in files newly added to the application may not be detected. Error: {e}" ) ;
484- return ;
485- }
486- } ;
487- if let Err ( e) = watchexec. reconfigure ( rt) {
474+ if let Err ( e) = rtf. build_config ( & watchexec. config ) . await {
488475 tracing:: error!( "Unable to re-configure watcher after manifest change. Changes in files newly added to the application may not be detected. Error: {e}" ) ;
489- }
476+ } ;
490477 }
491478 Self :: Dummy => ( ) ,
492479 }
0 commit comments