diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 7260c093..14fa5da6 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -434,7 +434,7 @@ dependencies = [ [[package]] name = "backend" -version = "0.2.0" +version = "0.2.2" dependencies = [ "anyhow", "async-trait", diff --git a/backend/src/routes/updates.rs b/backend/src/routes/updates.rs index 3a150d36..6488d299 100644 --- a/backend/src/routes/updates.rs +++ b/backend/src/routes/updates.rs @@ -122,10 +122,21 @@ pub async fn install_update( State(_state): State, Json(payload): Json, ) -> Result, AppError> { + tracing::info!( + "Update installation requested for version: {}", + payload.version + ); + let current_version = env!("CARGO_PKG_VERSION").to_string(); + tracing::info!("Current version: {}", current_version); // Safety check: don't downgrade if !version_compare(¤t_version, &payload.version) { + tracing::warn!( + "Update rejected: Cannot install version {} (current: {})", + payload.version, + current_version + ); return Ok(Json(UpdateResponse { success: false, message: "Cannot install an older or same version".to_string(), @@ -141,11 +152,18 @@ pub async fn install_update( possible_paths.push(dir.join("scripts/update.sh")); } + tracing::debug!("Searching for update script in: {:?}", possible_paths); + let script_path = possible_paths .iter() .find(|&p: &&std::path::PathBuf| p.exists()) .ok_or_else(|| { - AppError::InternalError("Update script not found in any expected location".to_string()) + let error_msg = format!( + "Update script not found in any expected location. Searched paths: {:?}", + possible_paths + ); + tracing::error!("{}", error_msg); + AppError::InternalError(error_msg) })? .clone(); @@ -268,9 +286,15 @@ pub enum AppError { impl IntoResponse for AppError { fn into_response(self) -> Response { - let (status, message) = match self { - AppError::InternalError(msg) => (StatusCode::INTERNAL_SERVER_ERROR, msg), - AppError::NotFound(msg) => (StatusCode::NOT_FOUND, msg), + let (status, message) = match &self { + AppError::InternalError(msg) => { + tracing::error!("Internal error: {}", msg); + (StatusCode::INTERNAL_SERVER_ERROR, msg.clone()) + } + AppError::NotFound(msg) => { + tracing::warn!("Not found: {}", msg); + (StatusCode::NOT_FOUND, msg.clone()) + } }; (status, Json(serde_json::json!({ "error": message }))).into_response() diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 34653b6c..c2f272b6 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "frontend", - "version": "0.0.8", + "version": "0.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "frontend", - "version": "0.0.8", + "version": "0.2.2", "dependencies": { "@icons-pack/svelte-simple-icons": "^6.5.0", "@tailwindcss/typography": "0.5.19",