Skip to content

Commit 8c2536c

Browse files
committed
small refactoring
1 parent df497ca commit 8c2536c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

libsql/src/local/connection.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ impl Connection {
7676
// disabled so that we can sync our changes back to a remote
7777
// server.
7878
conn.query("PRAGMA journal_mode = WAL", Params::None)?;
79-
unsafe {
80-
ffi::libsql_wal_disable_checkpoint(conn.raw);
81-
}
79+
conn.wal_disable_checkpoint()?;
8280
}
8381
Ok(conn)
8482
}
@@ -554,6 +552,16 @@ impl Connection {
554552
Ok(buf)
555553
}
556554

555+
fn wal_disable_checkpoint(&self) -> Result<()> {
556+
let rc = unsafe { libsql_sys::ffi::libsql_wal_disable_checkpoint(self.handle()) };
557+
if rc != 0 {
558+
return Err(crate::errors::Error::SqliteFailure(
559+
rc as std::ffi::c_int,
560+
format!("wal_disable_checkpoint failed"),
561+
));
562+
}
563+
Ok(())
564+
}
557565
fn wal_insert_begin(&self) -> Result<()> {
558566
let rc = unsafe { libsql_sys::ffi::libsql_wal_insert_begin(self.handle()) };
559567
if rc != 0 {

0 commit comments

Comments
 (0)