From 00d771c15fdd8a629f2a96dcc0597a64ee95e54e Mon Sep 17 00:00:00 2001 From: perf3ct Date: Wed, 25 Jun 2025 20:00:09 +0000 Subject: [PATCH] fix(server): resolve compilation issues due to increased logging --- src/config.rs | 8 ++++---- src/db/sources.rs | 14 +++++++++----- src/main.rs | 17 +++++++++-------- src/webdav_service.rs | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/config.rs b/src/config.rs index 98c7173..d47f63e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -34,7 +34,7 @@ impl Config { // Log all environment variable loading with detailed information println!("\nšŸ“‹ CONFIGURATION LOADING:"); - println!("=".repeat(50)); + println!("{}", "=".repeat(50)); // Database Configuration let database_url = match env::var("DATABASE_URL") { @@ -338,7 +338,7 @@ impl Config { }; println!("\nšŸ” CONFIGURATION VALIDATION:"); - println!("=".repeat(50)); + println!("{}", "=".repeat(50)); // Validate server address format if !config.server_address.contains(':') { @@ -362,7 +362,7 @@ impl Config { config.validate_paths()?; println!("\nšŸ“Š CONFIGURATION SUMMARY:"); - println!("=".repeat(50)); + println!("{}", "=".repeat(50)); println!("🌐 Server will bind to: {}", config.server_address); println!("šŸ“ Upload directory: {}", config.upload_path); println!("šŸ‘ļø Watch directory: {}", config.watch_folder); @@ -375,7 +375,7 @@ impl Config { // Warning checks println!("\nāš ļø CONFIGURATION WARNINGS:"); - println!("=".repeat(50)); + println!("{}", "=".repeat(50)); if config.jwt_secret == "your-secret-key" { println!("🚨 SECURITY WARNING: Using default JWT secret! Set JWT_SECRET environment variable in production!"); } diff --git a/src/db/sources.rs b/src/db/sources.rs index 9b2d07a..40a9241 100644 --- a/src/db/sources.rs +++ b/src/db/sources.rs @@ -2,6 +2,7 @@ use anyhow::Result; use chrono::Utc; use sqlx::Row; use uuid::Uuid; +use tracing::{info, warn, error}; use super::Database; @@ -312,13 +313,16 @@ impl Database { let source = crate::models::Source { id: source_id, user_id: row.get("user_id"), - name: source_name, - source_type: source_type_str.try_into() - .map_err(|e| anyhow::anyhow!("Invalid source type '{}' for source '{}': {}", source_type_str, row.get::("name"), e))?, + name: source_name.clone(), + source_type: source_type_str.clone().try_into() + .map_err(|e| anyhow::anyhow!("Invalid source type '{}' for source '{}': {}", source_type_str, source_name, e))?, enabled: row.get("enabled"), config: config_json, - status: row.get::("status").try_into() - .map_err(|e| anyhow::anyhow!("Invalid source status '{}' for source '{}': {}", row.get::("status"), row.get::("name"), e))?, + status: { + let status_str: String = row.get("status"); + status_str.clone().try_into() + .map_err(|e| anyhow::anyhow!("Invalid source status '{}' for source '{}': {}", status_str, source_name, e))? + }, last_sync_at: row.get("last_sync_at"), last_error: row.get("last_error"), last_error_at: row.get("last_error_at"), diff --git a/src/main.rs b/src/main.rs index 25ada2d..2bb97a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ use sqlx::Row; use std::sync::Arc; use tower_http::{cors::CorsLayer, services::{ServeDir, ServeFile}}; use tracing::{info, error, warn}; +use anyhow; use readur::{config::Config, db::Database, AppState, *}; @@ -50,11 +51,11 @@ fn determine_static_files_path() -> std::path::PathBuf { } #[tokio::main] -async fn main() -> Result<(), Box> { +async fn main() -> anyhow::Result<()> { tracing_subscriber::fmt::init(); println!("\nšŸš€ READUR APPLICATION STARTUP"); - println!("=".repeat(60)); + println!("{}", "=".repeat(60)); // Load and validate configuration with comprehensive logging let config = match Config::from_env() { @@ -72,7 +73,7 @@ async fn main() -> Result<(), Box> { // Log critical configuration values that affect startup println!("\nšŸ”— STARTUP CONFIGURATION:"); - println!("=".repeat(50)); + println!("{}", "=".repeat(50)); println!("🌐 Server will start on: {}", config.server_address); // Parse database URL safely without exposing credentials let db_info = if let Some(at_pos) = config.database_url.find('@') { @@ -119,7 +120,7 @@ async fn main() -> Result<(), Box> { // Create separate database pools for different workloads println!("\nšŸ—„ļø DATABASE CONNECTION:"); - println!("=".repeat(50)); + println!("{}", "=".repeat(50)); let web_db = match Database::new_with_pool_config(&config.database_url, 20, 2).await { Ok(db) => { @@ -352,7 +353,7 @@ async fn main() -> Result<(), Box> { // Create universal source scheduler with background state (handles WebDAV, Local, S3) println!("\nšŸ“… SCHEDULER INITIALIZATION:"); - println!("=".repeat(50)); + println!("{}", "=".repeat(50)); let source_scheduler = Arc::new(readur::source_scheduler::SourceScheduler::new(background_state.clone())); println!("āœ… Universal source scheduler created (handles WebDAV, Local, S3)"); @@ -416,7 +417,7 @@ async fn main() -> Result<(), Box> { .with_state(web_state.clone()); println!("\n🌐 STARTING HTTP SERVER:"); - println!("=".repeat(50)); + println!("{}", "=".repeat(50)); let listener = match tokio::net::TcpListener::bind(&config.server_address).await { Ok(listener) => { @@ -435,13 +436,13 @@ async fn main() -> Result<(), Box> { }; println!("\nšŸŽ‰ READUR APPLICATION READY!"); - println!("=".repeat(60)); + println!("{}", "=".repeat(60)); println!("🌐 Server: http://{}", config.server_address); println!("šŸ“ Upload Directory: {}", config.upload_path); println!("šŸ‘ļø Watch Directory: {}", config.watch_folder); println!("šŸ”„ Source Scheduler: Will start in 30 seconds"); println!("šŸ“‹ Check logs above for any configuration warnings"); - println!("=".repeat(60)); + println!("{}", "=".repeat(60)); info!("šŸš€ Readur server is now running and accepting connections"); diff --git a/src/webdav_service.rs b/src/webdav_service.rs index 0065434..2cc4302 100644 --- a/src/webdav_service.rs +++ b/src/webdav_service.rs @@ -245,7 +245,7 @@ impl WebDAVService { info!("šŸ”— Constructed test URL: {}", test_url); - let response = self.client + let resp = self.client .request(Method::from_bytes(b"PROPFIND").unwrap(), &test_url) .basic_auth(&test_config.username, Some(&test_config.password)) .header("Depth", "0")