@@ -29,33 +29,38 @@ async fn pull_loop(workspace: PathBuf, db: Arc<BrainDb>, interval_secs: u64) {
2929 tokio:: time:: sleep ( interval) . await ;
3030
3131 let ws = workspace. clone ( ) ;
32- match tokio:: process:: Command :: new ( "git" )
33- . args ( [ "pull" , "--rebase" , "origin" , "main" ] )
34- . current_dir ( & ws)
35- . output ( )
36- . await
37- {
38- Ok ( out) if out. status . success ( ) => {
32+ let output_res = tokio:: task:: spawn_blocking ( move || {
33+ std:: process:: Command :: new ( "git" )
34+ . args ( [ "pull" , "--rebase" , "origin" , "main" ] )
35+ . current_dir ( & ws)
36+ . output ( )
37+ } )
38+ . await ;
39+
40+ match output_res {
41+ Ok ( Ok ( out) ) if out. status . success ( ) => {
3942 let stdout = String :: from_utf8_lossy ( & out. stdout ) ;
4043 eprintln ! ( "git pull: ok — {}" , stdout. trim( ) ) ;
4144
45+ let ws_reindex = workspace. clone ( ) ;
4246 // Re-index vault so FTS5 reflects any new notes from PC.
4347 let idx = indexer. clone ( ) ;
44- match tokio:: task:: spawn_blocking ( move || idx. scan ( & ws ) ) . await {
48+ match tokio:: task:: spawn_blocking ( move || idx. scan ( & ws_reindex ) ) . await {
4549 Ok ( Ok ( stats) ) => eprintln ! ( "vault re-index: {stats}" ) ,
4650 Ok ( Err ( e) ) => eprintln ! ( "vault re-index warning: {e}" ) ,
4751 Err ( e) => eprintln ! ( "vault re-index task error: {e}" ) ,
4852 }
4953 }
50- Ok ( out) => {
54+ Ok ( Ok ( out) ) => {
5155 let stderr = String :: from_utf8_lossy ( & out. stderr ) ;
5256 eprintln ! (
5357 "git pull: non-zero exit ({}): {}" ,
5458 out. status,
5559 stderr. trim( )
5660 ) ;
5761 }
58- Err ( e) => eprintln ! ( "git pull: failed to spawn: {e}" ) ,
62+ Ok ( Err ( e) ) => eprintln ! ( "git pull: failed to spawn: {e}" ) ,
63+ Err ( e) => eprintln ! ( "git pull: task panicked: {e}" ) ,
5964 }
6065 }
6166}
0 commit comments