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::{fs, thread};
|
||||
|
||||
use log::error;
|
||||
use rusqlite::Connection;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
|
||||
|
|
@ -50,7 +51,9 @@ fn run(mut conn: Connection, mut rx: mpsc::UnboundedReceiver<Request>) {
|
|||
match request {
|
||||
Request::Close(tx) => {
|
||||
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
|
||||
// has been closed properly.
|
||||
drop(conn);
|
||||
|
|
@ -58,10 +61,16 @@ fn run(mut conn: Connection, mut rx: mpsc::UnboundedReceiver<Request>) {
|
|||
break;
|
||||
}
|
||||
Request::Gc(tx) => {
|
||||
let _ = conn.execute_batch("ANALYZE; VACUUM;");
|
||||
if let Err(e) = conn.execute_batch("ANALYZE; VACUUM;") {
|
||||
error!("{e}");
|
||||
}
|
||||
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 {
|
||||
pub(super) fn perform(self, conn: &mut Connection) {
|
||||
// TODO Handle this result
|
||||
let _ = match self {
|
||||
pub(super) fn perform(self, conn: &mut Connection) -> rusqlite::Result<()> {
|
||||
match self {
|
||||
$( Self::$var(request) => request.perform(conn), )*
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue