diff --git a/src/modes/server.rs b/src/modes/server.rs index 4cfe7bc..25417ff 100644 --- a/src/modes/server.rs +++ b/src/modes/server.rs @@ -94,23 +94,21 @@ pub fn mode_server( // We need to move the connection into the async runtime let rt = tokio::runtime::Runtime::new()?; - rt.block_on(run_server(config, conn, data_path, args)) + // Take ownership of the connection and move it into the async runtime + let owned_conn = std::mem::replace(conn, rusqlite::Connection::open_in_memory()?); + rt.block_on(run_server(config, owned_conn, data_path, args)) } async fn run_server( config: ServerConfig, - _conn: &mut rusqlite::Connection, + conn: rusqlite::Connection, data_dir: PathBuf, args: &Args, ) -> Result<()> { debug!("Starting REST HTTP server on {}", config.address); - // Create a new database connection for the server - // Note: This is a simplified approach. In production, you'd want a connection pool - let mut db_path = data_dir.clone(); - db_path.push("keep-1.db"); - let new_conn = crate::db::open(db_path)?; - let db_conn = Arc::new(Mutex::new(new_conn)); + // Use the existing database connection + let db_conn = Arc::new(Mutex::new(conn)); let state = AppState { db: db_conn,