From a00952a3777cd2d15746f8695c196a8bd2ff4e63 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Sat, 16 Aug 2025 12:29:32 -0300 Subject: [PATCH] fix: remove unused delete_item handler and add accessors for unused fields Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) --- src/args.rs | 10 ++++++++ src/config.rs | 6 +++++ src/modes/server/api/item.rs | 48 ------------------------------------ src/modes/server/common.rs | 10 ++++++++ 4 files changed, 26 insertions(+), 48 deletions(-) diff --git a/src/args.rs b/src/args.rs index 5d5982b..854808c 100644 --- a/src/args.rs +++ b/src/args.rs @@ -190,3 +190,13 @@ impl FromStr for KeyValue { } } } + +impl KeyValue { + pub fn key(&self) -> &str { + &self.key + } + + pub fn value(&self) -> &str { + &self.value + } +} diff --git a/src/config.rs b/src/config.rs index f17eb1c..fed2ecf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -46,6 +46,12 @@ pub struct Settings { pub digest: Option, } +impl Settings { + pub fn verbose(&self) -> u8 { + self.verbose + } +} + impl Settings { /// Create unified settings from config and args with proper priority pub fn new(args: &Args, default_dir: PathBuf) -> Result { diff --git a/src/modes/server/api/item.rs b/src/modes/server/api/item.rs index 8f6f8c6..c6a3933 100644 --- a/src/modes/server/api/item.rs +++ b/src/modes/server/api/item.rs @@ -161,54 +161,6 @@ pub async fn handle_post_item( Ok(Json(response)) } -#[utoipa::path( - delete, - path = "/api/item/{item_id}", - operation_id = "delete_item", - summary = "Delete stored item", - description = "Permanently delete an item and all its associated metadata, tags, and stored content. This operation cannot be undone. The item's compressed data file and all database records will be removed.", - responses( - (status = 200, description = "Successfully deleted item and all associated metadata, tags, and content"), - (status = 400, description = "Bad request - Invalid item ID (must be a positive integer)"), - (status = 401, description = "Unauthorized - Invalid or missing authentication credentials"), - (status = 404, description = "Item not found - No item exists with the specified ID"), - (status = 500, description = "Internal server error - Failed to delete item due to database or filesystem error") - ), - params( - ("item_id" = i64, Path, description = "Unique identifier of the item to delete (must be a positive integer)") - ), - security( - ("bearerAuth" = []) - ), - tag = "item" -)] -pub async fn handle_delete_item( - State(state): State, - Path(item_id): Path, -) -> Result>, StatusCode> { - // Validate that item ID is positive to prevent path traversal issues - if item_id <= 0 { - return Err(StatusCode::BAD_REQUEST); - } - - let mut conn = state.db.lock().await; - - if let Some(item) = db::get_item(&mut *conn, item_id).map_err(|e| { - warn!("Failed to get item {} for deletion: {}", item_id, e); - StatusCode::INTERNAL_SERVER_ERROR - })? { - db::delete_item(&mut *conn, item).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; - - let response = ApiResponse::<()> { - success: true, - data: None, - error: None, - }; - Ok(Json(response)) - } else { - Err(StatusCode::NOT_FOUND) - } -} #[utoipa::path( get, diff --git a/src/modes/server/common.rs b/src/modes/server/common.rs index f22a804..5ebe214 100644 --- a/src/modes/server/common.rs +++ b/src/modes/server/common.rs @@ -32,6 +32,16 @@ pub struct AppState { pub password_hash: Option, } +impl AppState { + pub fn password(&self) -> Option<&String> { + self.password.as_ref() + } + + pub fn password_hash(&self) -> Option<&String> { + self.password_hash.as_ref() + } +} + #[derive(Serialize, Deserialize, ToSchema)] #[schema(description = "Standard API response wrapper containing success status, data payload, and error information")] pub struct ApiResponse {