Skip to content
Merged
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
16 changes: 11 additions & 5 deletions libsql/src/database/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ cfg_core! {
use crate::EncryptionConfig;
}

use crate::{Database, Result};

use super::DbType;
use crate::{Database, Result};

/// A builder for [`Database`]. This struct can be used to build
/// all variants of [`Database`]. These variants include:
Expand Down Expand Up @@ -644,11 +643,18 @@ cfg_sync! {
}

let mut bg_abort: Option<std::sync::Arc<crate::sync::DropAbort>> = None;
let conn = db.connect()?;

let sync_ctx = db.sync_ctx.as_ref().unwrap().clone();

if let Some(sync_interval) = sync_interval {
let sync_ctx = db.sync_ctx.as_ref().unwrap().clone();
{
let mut ctx = sync_ctx.lock().await;
crate::sync::bootstrap_db(&mut ctx).await?;
}

// db.connect creates a local db file, so it is important that we always call
// `bootstrap_db` (for synced dbs) before calling connect. Otherwise, the sync
// protocol skips calling `export` endpoint causing slowdown in initial bootstrap.
let conn = db.connect()?;
let jh = tokio::spawn(
async move {
loop {
Expand Down
Loading