db: switch to sqlite as the primary backend

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I6a6a69648f81d0d094e11a3e0f0a19d3b8eccd5d
This commit is contained in:
raf 2025-08-12 18:54:07 +03:00
commit 4f725425fc
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
12 changed files with 246 additions and 274 deletions

View file

@ -95,7 +95,7 @@ fn report_error<T>(result: Result<T, impl std::fmt::Display>, context: &str) ->
}
/// Watch clipboard and store changes
fn run_daemon(db: &db::SledClipboardDb, max_dedupe_search: u64, max_items: u64) {
fn run_daemon(db: &db::SqliteClipboardDb, max_dedupe_search: u64, max_items: u64) {
log::info!("Starting clipboard watch daemon (Wayland)");
let mut last_contents: Option<Vec<u8>> = None;
@ -149,12 +149,18 @@ fn main() {
.join("db")
});
let sled_db = sled::open(&db_path).unwrap_or_else(|e| {
log::error!("Failed to open database: {e}");
let conn = rusqlite::Connection::open(&db_path).unwrap_or_else(|e| {
log::error!("Failed to open SQLite database: {e}");
process::exit(1);
});
let db = db::SledClipboardDb { db: sled_db };
let db = match db::SqliteClipboardDb::new(conn) {
Ok(db) => db,
Err(e) => {
log::error!("Failed to initialize SQLite database: {e}");
process::exit(1);
}
};
match cli.command {
Some(Command::Store) => {