fix(server): resolve compilation issues due to increased logging

This commit is contained in:
perf3ct 2025-06-25 20:00:09 +00:00
parent bcd03bf0d4
commit 00d771c15f
4 changed files with 23 additions and 18 deletions

View File

@ -34,7 +34,7 @@ impl Config {
// Log all environment variable loading with detailed information // Log all environment variable loading with detailed information
println!("\n📋 CONFIGURATION LOADING:"); println!("\n📋 CONFIGURATION LOADING:");
println!("=".repeat(50)); println!("{}", "=".repeat(50));
// Database Configuration // Database Configuration
let database_url = match env::var("DATABASE_URL") { let database_url = match env::var("DATABASE_URL") {
@ -338,7 +338,7 @@ impl Config {
}; };
println!("\n🔍 CONFIGURATION VALIDATION:"); println!("\n🔍 CONFIGURATION VALIDATION:");
println!("=".repeat(50)); println!("{}", "=".repeat(50));
// Validate server address format // Validate server address format
if !config.server_address.contains(':') { if !config.server_address.contains(':') {
@ -362,7 +362,7 @@ impl Config {
config.validate_paths()?; config.validate_paths()?;
println!("\n📊 CONFIGURATION SUMMARY:"); println!("\n📊 CONFIGURATION SUMMARY:");
println!("=".repeat(50)); println!("{}", "=".repeat(50));
println!("🌐 Server will bind to: {}", config.server_address); println!("🌐 Server will bind to: {}", config.server_address);
println!("📁 Upload directory: {}", config.upload_path); println!("📁 Upload directory: {}", config.upload_path);
println!("👁️ Watch directory: {}", config.watch_folder); println!("👁️ Watch directory: {}", config.watch_folder);
@ -375,7 +375,7 @@ impl Config {
// Warning checks // Warning checks
println!("\n⚠️ CONFIGURATION WARNINGS:"); println!("\n⚠️ CONFIGURATION WARNINGS:");
println!("=".repeat(50)); println!("{}", "=".repeat(50));
if config.jwt_secret == "your-secret-key" { if config.jwt_secret == "your-secret-key" {
println!("🚨 SECURITY WARNING: Using default JWT secret! Set JWT_SECRET environment variable in production!"); println!("🚨 SECURITY WARNING: Using default JWT secret! Set JWT_SECRET environment variable in production!");
} }

View File

@ -2,6 +2,7 @@ use anyhow::Result;
use chrono::Utc; use chrono::Utc;
use sqlx::Row; use sqlx::Row;
use uuid::Uuid; use uuid::Uuid;
use tracing::{info, warn, error};
use super::Database; use super::Database;
@ -312,13 +313,16 @@ impl Database {
let source = crate::models::Source { let source = crate::models::Source {
id: source_id, id: source_id,
user_id: row.get("user_id"), user_id: row.get("user_id"),
name: source_name, name: source_name.clone(),
source_type: source_type_str.try_into() source_type: source_type_str.clone().try_into()
.map_err(|e| anyhow::anyhow!("Invalid source type '{}' for source '{}': {}", source_type_str, row.get::<String, _>("name"), e))?, .map_err(|e| anyhow::anyhow!("Invalid source type '{}' for source '{}': {}", source_type_str, source_name, e))?,
enabled: row.get("enabled"), enabled: row.get("enabled"),
config: config_json, config: config_json,
status: row.get::<String, _>("status").try_into() status: {
.map_err(|e| anyhow::anyhow!("Invalid source status '{}' for source '{}': {}", row.get::<String, _>("status"), row.get::<String, _>("name"), e))?, 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_sync_at: row.get("last_sync_at"),
last_error: row.get("last_error"), last_error: row.get("last_error"),
last_error_at: row.get("last_error_at"), last_error_at: row.get("last_error_at"),

View File

@ -6,6 +6,7 @@ use sqlx::Row;
use std::sync::Arc; use std::sync::Arc;
use tower_http::{cors::CorsLayer, services::{ServeDir, ServeFile}}; use tower_http::{cors::CorsLayer, services::{ServeDir, ServeFile}};
use tracing::{info, error, warn}; use tracing::{info, error, warn};
use anyhow;
use readur::{config::Config, db::Database, AppState, *}; use readur::{config::Config, db::Database, AppState, *};
@ -50,11 +51,11 @@ fn determine_static_files_path() -> std::path::PathBuf {
} }
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt::init(); tracing_subscriber::fmt::init();
println!("\n🚀 READUR APPLICATION STARTUP"); println!("\n🚀 READUR APPLICATION STARTUP");
println!("=".repeat(60)); println!("{}", "=".repeat(60));
// Load and validate configuration with comprehensive logging // Load and validate configuration with comprehensive logging
let config = match Config::from_env() { let config = match Config::from_env() {
@ -72,7 +73,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Log critical configuration values that affect startup // Log critical configuration values that affect startup
println!("\n🔗 STARTUP CONFIGURATION:"); println!("\n🔗 STARTUP CONFIGURATION:");
println!("=".repeat(50)); println!("{}", "=".repeat(50));
println!("🌐 Server will start on: {}", config.server_address); println!("🌐 Server will start on: {}", config.server_address);
// Parse database URL safely without exposing credentials // Parse database URL safely without exposing credentials
let db_info = if let Some(at_pos) = config.database_url.find('@') { let db_info = if let Some(at_pos) = config.database_url.find('@') {
@ -119,7 +120,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create separate database pools for different workloads // Create separate database pools for different workloads
println!("\n🗄️ DATABASE CONNECTION:"); 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 { let web_db = match Database::new_with_pool_config(&config.database_url, 20, 2).await {
Ok(db) => { Ok(db) => {
@ -352,7 +353,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create universal source scheduler with background state (handles WebDAV, Local, S3) // Create universal source scheduler with background state (handles WebDAV, Local, S3)
println!("\n📅 SCHEDULER INITIALIZATION:"); println!("\n📅 SCHEDULER INITIALIZATION:");
println!("=".repeat(50)); println!("{}", "=".repeat(50));
let source_scheduler = Arc::new(readur::source_scheduler::SourceScheduler::new(background_state.clone())); let source_scheduler = Arc::new(readur::source_scheduler::SourceScheduler::new(background_state.clone()));
println!("✅ Universal source scheduler created (handles WebDAV, Local, S3)"); println!("✅ Universal source scheduler created (handles WebDAV, Local, S3)");
@ -416,7 +417,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_state(web_state.clone()); .with_state(web_state.clone());
println!("\n🌐 STARTING HTTP SERVER:"); println!("\n🌐 STARTING HTTP SERVER:");
println!("=".repeat(50)); println!("{}", "=".repeat(50));
let listener = match tokio::net::TcpListener::bind(&config.server_address).await { let listener = match tokio::net::TcpListener::bind(&config.server_address).await {
Ok(listener) => { Ok(listener) => {
@ -435,13 +436,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}; };
println!("\n🎉 READUR APPLICATION READY!"); println!("\n🎉 READUR APPLICATION READY!");
println!("=".repeat(60)); println!("{}", "=".repeat(60));
println!("🌐 Server: http://{}", config.server_address); println!("🌐 Server: http://{}", config.server_address);
println!("📁 Upload Directory: {}", config.upload_path); println!("📁 Upload Directory: {}", config.upload_path);
println!("👁️ Watch Directory: {}", config.watch_folder); println!("👁️ Watch Directory: {}", config.watch_folder);
println!("🔄 Source Scheduler: Will start in 30 seconds"); println!("🔄 Source Scheduler: Will start in 30 seconds");
println!("📋 Check logs above for any configuration warnings"); println!("📋 Check logs above for any configuration warnings");
println!("=".repeat(60)); println!("{}", "=".repeat(60));
info!("🚀 Readur server is now running and accepting connections"); info!("🚀 Readur server is now running and accepting connections");

View File

@ -245,7 +245,7 @@ impl WebDAVService {
info!("🔗 Constructed test URL: {}", test_url); info!("🔗 Constructed test URL: {}", test_url);
let response = self.client let resp = self.client
.request(Method::from_bytes(b"PROPFIND").unwrap(), &test_url) .request(Method::from_bytes(b"PROPFIND").unwrap(), &test_url)
.basic_auth(&test_config.username, Some(&test_config.password)) .basic_auth(&test_config.username, Some(&test_config.password))
.header("Depth", "0") .header("Depth", "0")