Log sql errors in vault
This commit is contained in:
parent
37df869695
commit
c07941b374
2 changed files with 15 additions and 7 deletions
15
src/vault.rs
15
src/vault.rs
|
|
@ -5,6 +5,7 @@ mod prepare;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::{fs, thread};
|
use std::{fs, thread};
|
||||||
|
|
||||||
|
use log::error;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
use tokio::sync::{mpsc, oneshot};
|
use tokio::sync::{mpsc, oneshot};
|
||||||
|
|
||||||
|
|
@ -50,7 +51,9 @@ fn run(mut conn: Connection, mut rx: mpsc::UnboundedReceiver<Request>) {
|
||||||
match request {
|
match request {
|
||||||
Request::Close(tx) => {
|
Request::Close(tx) => {
|
||||||
println!("Closing vault");
|
println!("Closing vault");
|
||||||
let _ = conn.execute_batch("PRAGMA optimize");
|
if let Err(e) = conn.execute_batch("PRAGMA optimize") {
|
||||||
|
error!("{e}");
|
||||||
|
}
|
||||||
// Ensure `Vault::close` exits only after the sqlite connection
|
// Ensure `Vault::close` exits only after the sqlite connection
|
||||||
// has been closed properly.
|
// has been closed properly.
|
||||||
drop(conn);
|
drop(conn);
|
||||||
|
|
@ -58,10 +61,16 @@ fn run(mut conn: Connection, mut rx: mpsc::UnboundedReceiver<Request>) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Request::Gc(tx) => {
|
Request::Gc(tx) => {
|
||||||
let _ = conn.execute_batch("ANALYZE; VACUUM;");
|
if let Err(e) = conn.execute_batch("ANALYZE; VACUUM;") {
|
||||||
|
error!("{e}");
|
||||||
|
}
|
||||||
drop(tx);
|
drop(tx);
|
||||||
}
|
}
|
||||||
Request::Euph(r) => r.perform(&mut conn),
|
Request::Euph(r) => {
|
||||||
|
if let Err(e) = r.perform(&mut conn) {
|
||||||
|
error!("{e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -217,11 +217,10 @@ macro_rules! requests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EuphRequest {
|
impl EuphRequest {
|
||||||
pub(super) fn perform(self, conn: &mut Connection) {
|
pub(super) fn perform(self, conn: &mut Connection) -> rusqlite::Result<()> {
|
||||||
// TODO Handle this result
|
match self {
|
||||||
let _ = match self {
|
|
||||||
$( Self::$var(request) => request.perform(conn), )*
|
$( Self::$var(request) => request.perform(conn), )*
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue