fix: remove unused imports and fix undefined behavior from mem::zeroed

Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-10 21:30:16 -03:00
parent 64789ef48b
commit 4be4831334

View File

@@ -1,13 +1,13 @@
use anyhow::{anyhow, Result}; use anyhow::Result;
use axum::{ use axum::{
extract::{Path, Query, State}, extract::{Path, Query, State},
http::{HeaderMap, StatusCode}, http::{HeaderMap, StatusCode},
response::{Html, Json}, response::{Html, Json},
routing::{delete, get, put}, routing::get,
Router, Router,
}; };
use clap::Command; use clap::Command;
use log::{debug, info, warn}; use log::{info, warn};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::json; use serde_json::json;
use std::collections::HashMap; use std::collections::HashMap;
@@ -18,8 +18,7 @@ use std::sync::Arc;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use tower_http::cors::CorsLayer; use tower_http::cors::CorsLayer;
use crate::db::{self, Item, Tag, Meta}; use crate::db;
use crate::modes::common::{format_size, OutputFormat};
use crate::Args; use crate::Args;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@@ -78,7 +77,7 @@ struct TagsQuery {
} }
pub fn mode_server( pub fn mode_server(
cmd: &mut Command, _cmd: &mut Command,
args: &Args, args: &Args,
conn: &mut rusqlite::Connection, conn: &mut rusqlite::Connection,
data_path: PathBuf, data_path: PathBuf,
@@ -97,14 +96,17 @@ pub fn mode_server(
async fn run_server( async fn run_server(
config: ServerConfig, config: ServerConfig,
conn: &mut rusqlite::Connection, _conn: &mut rusqlite::Connection,
data_dir: PathBuf, data_dir: PathBuf,
) -> Result<()> { ) -> Result<()> {
info!("Starting REST HTTP server on {}", config.address); info!("Starting REST HTTP server on {}", config.address);
// Move connection into Arc<Mutex<>> for sharing across async tasks // Create a new database connection for the server
// Note: This is a simplified approach. In production, you'd want a connection pool // Note: This is a simplified approach. In production, you'd want a connection pool
let db_conn = Arc::new(Mutex::new(std::mem::replace(conn, unsafe { std::mem::zeroed() }))); 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));
let state = AppState { let state = AppState {
db: db_conn, db: db_conn,