Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion libsql/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))),
}
}
Expand Down
2 changes: 1 addition & 1 deletion libsql/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
6 changes: 3 additions & 3 deletions libsql/src/sync/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Loading