mirror of
https://github.com/tursodatabase/libsql.git
synced 2025-09-20 21:29:46 +00:00
@@ -392,7 +392,14 @@ cfg_replication! {
|
||||
#[cfg(feature = "replication")]
|
||||
DbType::Sync { db, encryption_config: _ } => db.sync().await,
|
||||
#[cfg(feature = "sync")]
|
||||
DbType::Offline { db, .. } => db.sync_offline().await,
|
||||
DbType::Offline { db, remote_writes: false, .. } => db.sync_offline().await,
|
||||
#[cfg(feature = "sync")]
|
||||
DbType::Offline { db, remote_writes: true, .. } => {
|
||||
let mut sync_ctx = db.sync_ctx.as_ref().unwrap().lock().await;
|
||||
crate::sync::bootstrap_db(&mut sync_ctx).await?;
|
||||
let conn = db.connect()?;
|
||||
crate::sync::try_pull(&mut sync_ctx, &conn).await
|
||||
},
|
||||
_ => Err(Error::SyncNotSupported(format!("{:?}", self.db_type))),
|
||||
}
|
||||
}
|
||||
|
@@ -814,7 +814,7 @@ async fn try_push(
|
||||
})
|
||||
}
|
||||
|
||||
async fn try_pull(
|
||||
pub async fn try_pull(
|
||||
sync_ctx: &mut SyncContext,
|
||||
conn: &Connection,
|
||||
) -> Result<crate::database::Replicated> {
|
||||
|
@@ -22,21 +22,21 @@ impl Stmt for SyncedStatement {
|
||||
async fn execute(&mut self, params: &Params) -> Result<usize> {
|
||||
let result = self.inner.execute(params).await;
|
||||
let mut context = self.context.lock().await;
|
||||
let _ = crate::sync::sync_offline(&mut context, &self.conn).await;
|
||||
crate::sync::try_pull(&mut context, &self.conn).await?;
|
||||
result
|
||||
}
|
||||
|
||||
async fn query(&mut self, params: &Params) -> Result<Rows> {
|
||||
let result = self.inner.query(params).await;
|
||||
let mut context = self.context.lock().await;
|
||||
let _ = crate::sync::sync_offline(&mut context, &self.conn).await;
|
||||
crate::sync::try_pull(&mut context, &self.conn).await?;
|
||||
result
|
||||
}
|
||||
|
||||
async fn run(&mut self, params: &Params) -> Result<()> {
|
||||
let result = self.inner.run(params).await;
|
||||
let mut context = self.context.lock().await;
|
||||
let _ = crate::sync::sync_offline(&mut context, &self.conn).await;
|
||||
crate::sync::try_pull(&mut context, &self.conn).await?;
|
||||
result
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user