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:
@@ -1,13 +1,13 @@
|
||||
use anyhow::{anyhow, Result};
|
||||
use anyhow::Result;
|
||||
use axum::{
|
||||
extract::{Path, Query, State},
|
||||
http::{HeaderMap, StatusCode},
|
||||
response::{Html, Json},
|
||||
routing::{delete, get, put},
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
use clap::Command;
|
||||
use log::{debug, info, warn};
|
||||
use log::{info, warn};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
use std::collections::HashMap;
|
||||
@@ -18,8 +18,7 @@ use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
use tower_http::cors::CorsLayer;
|
||||
|
||||
use crate::db::{self, Item, Tag, Meta};
|
||||
use crate::modes::common::{format_size, OutputFormat};
|
||||
use crate::db;
|
||||
use crate::Args;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -78,7 +77,7 @@ struct TagsQuery {
|
||||
}
|
||||
|
||||
pub fn mode_server(
|
||||
cmd: &mut Command,
|
||||
_cmd: &mut Command,
|
||||
args: &Args,
|
||||
conn: &mut rusqlite::Connection,
|
||||
data_path: PathBuf,
|
||||
@@ -97,14 +96,17 @@ pub fn mode_server(
|
||||
|
||||
async fn run_server(
|
||||
config: ServerConfig,
|
||||
conn: &mut rusqlite::Connection,
|
||||
_conn: &mut rusqlite::Connection,
|
||||
data_dir: PathBuf,
|
||||
) -> Result<()> {
|
||||
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
|
||||
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 {
|
||||
db: db_conn,
|
||||
|
||||
Reference in New Issue
Block a user