From 990b453c7322a55c3a562973818401a34c91cce7 Mon Sep 17 00:00:00 2001 From: Loudbook Date: Tue, 10 Dec 2024 20:02:41 -0500 Subject: [PATCH] Cleanup --- backend/src/delete_service.rs | 10 ++++++---- backend/src/main.rs | 11 +++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/backend/src/delete_service.rs b/backend/src/delete_service.rs index c314b85..848038f 100644 --- a/backend/src/delete_service.rs +++ b/backend/src/delete_service.rs @@ -64,10 +64,12 @@ impl DeleteHandler { if let Err(err) = mongo_service.delete_paste(paste_id).await { error!("Failed to delete paste from database: {:?}", err); } - if let id = &paste.id { - if let Err(err) = mongo_service.delete_paste(id).await { - error!("Failed to delete paste file: {}", err); - } + let id = &paste.id; + + if let Err(err) = mongo_service.delete_paste(id).await { + error!("Failed to delete paste file: {}", err); + } else { + warn!("Deleted paste file: {}", id); } } diff --git a/backend/src/main.rs b/backend/src/main.rs index 569b1f3..9e11a9c 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -11,11 +11,11 @@ use crate::controllers::get_controller::{get_content_handler, get_metadata_handl use crate::controllers::upload_controller::upload_handler; use crate::delete_service::DeleteHandler; use crate::mongodb_service::MongoService; -use actix_web::{web, App, HttpResponse, HttpServer, Responder}; +use actix_cors::Cors; +use actix_web::{web, App, HttpServer}; use dotenv::dotenv; use std::env; use std::sync::Arc; -use actix_cors::Cors; #[actix_web::main] async fn main() -> std::io::Result<()> { @@ -52,7 +52,7 @@ async fn main() -> std::io::Result<()> { let delete_handler = DeleteHandler::new(Arc::clone(&aws_service), Arc::clone(&mongo_service)); delete_handler.start_delete_loop(); - + HttpServer::new(move || { let cors = Cors::permissive(); @@ -67,9 +67,4 @@ async fn main() -> std::io::Result<()> { .bind(("0.0.0.0", 8080))? .run() .await -} - -async fn health_check() -> impl Responder { - println!("Health check"); - HttpResponse::Ok().body("OK") } \ No newline at end of file