@@ -6,7 +6,7 @@ use std::sync::Arc;
66
77use tracing:: Instrument as _;
88
9- use crate :: { sync :: DropAbort , Database , Result } ;
9+ use crate :: { Database , Result } ;
1010
1111use super :: DbType ;
1212
@@ -645,7 +645,7 @@ cfg_sync! {
645645 db. sync_ctx. as_ref( ) . unwrap( ) . lock( ) . await . set_push_batch_size( push_batch_size) ;
646646 }
647647
648- let mut bg_abort: Option <Arc <DropAbort >> = None ;
648+ let mut bg_abort: Option <Arc <crate :: sync :: DropAbort >> = None ;
649649 let conn = db. connect( ) ?;
650650
651651 let sync_ctx = db. sync_ctx. as_ref( ) . unwrap( ) . clone( ) ;
@@ -656,17 +656,22 @@ cfg_sync! {
656656 loop {
657657 tracing:: trace!( "trying to sync" ) ;
658658 let mut ctx = sync_ctx. lock( ) . await ;
659- if let Err ( e) = crate :: sync:: try_pull( & mut ctx, & conn) . await {
660- tracing:: error!( "sync error: {}" , e) ;
659+ if remote_writes {
660+ if let Err ( e) = crate :: sync:: try_pull( & mut ctx, & conn) . await {
661+ tracing:: error!( "sync error: {}" , e) ;
662+ }
663+ } else {
664+ if let Err ( e) = crate :: sync:: sync_offline( & mut ctx, & conn) . await {
665+ tracing:: error!( "sync error: {}" , e) ;
666+ }
661667 }
662-
663668 tokio:: time:: sleep( sync_interval) . await ;
664669 }
665670 }
666671 . instrument( tracing:: info_span!( "sync_interval" ) ) ,
667672 ) ;
668673
669- bg_abort. replace( Arc :: new( DropAbort ( jh. abort_handle( ) ) ) ) ;
674+ bg_abort. replace( Arc :: new( crate :: sync :: DropAbort ( jh. abort_handle( ) ) ) ) ;
670675 }
671676
672677 Ok ( Database {
0 commit comments