Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.
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
4 changes: 1 addition & 3 deletions sqld-libsql-bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ pub fn get_orig_wal_methods(with_bottomless: bool) -> anyhow::Result<*mut libsql
Ok(orig)
}

/// Opens a database with the regular wal methods in the directory pointed to by path
pub fn open_with_regular_wal(
path: impl AsRef<std::path::Path>,
flags: rusqlite::OpenFlags,
wal_hook: impl WalHook + 'static,
with_bottomless: bool,
) -> anyhow::Result<Connection> {
let path = path.as_ref().join("data");
unsafe {
let default_methods = get_orig_wal_methods(false)?;
let maybe_bottomless_methods = get_orig_wal_methods(with_bottomless)?;
Expand All @@ -49,7 +47,7 @@ pub fn open_with_regular_wal(
}
tracing::trace!(
"Opening a connection with regular WAL at {}",
path.display()
path.as_ref().display()
);
let conn = Connection::open_with_flags_and_wal(path, flags, WalMethodsHook::METHODS_NAME_STR)?;
conn.pragma_update(None, "journal_mode", "wal")?;
Expand Down
4 changes: 1 addition & 3 deletions sqld-libsql-bindings/src/mwal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ use std::sync::{Arc, Mutex};

pub use mwal::ffi;

/// Opens a database with the virtual wal methods in the directory pointed to by path
pub fn open_with_virtual_wal(
path: impl AsRef<std::path::Path>,
flags: rusqlite::OpenFlags,
vwal_methods: Arc<Mutex<mwal::ffi::libsql_wal_methods>>,
) -> anyhow::Result<rusqlite::Connection> {
let mut vwal_methods = vwal_methods.lock().map_err(|e| anyhow::anyhow!("{}", e))?;
let path = path.as_ref().join("data");
unsafe {
let register_err = super::ffi::libsql_wal_methods_register(
&mut *vwal_methods as *const mwal::ffi::libsql_wal_methods as _,
Expand All @@ -20,7 +18,7 @@ pub fn open_with_virtual_wal(
}
tracing::trace!(
"Opening a connection with virtual WAL at {}",
path.display()
path.as_ref().display()
);
let conn = rusqlite::Connection::open_with_flags_and_wal(path, flags, unsafe {
std::ffi::CStr::from_ptr(vwal_methods.name as *const _)
Expand Down
1 change: 1 addition & 0 deletions sqld/src/database/libsql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ impl LibSqlDb {
let (sender, receiver) = crossbeam::channel::unbounded::<Message>();

tokio::task::spawn_blocking(move || {
let path = path.as_ref().join("data");
let conn = open_db(
path,
#[cfg(feature = "mwal_backend")]
Expand Down