Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 28 additions & 4 deletions backend/src/routes/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,21 @@ pub async fn install_update(
State(_state): State<AppState>,
Json(payload): Json<UpdateRequest>,
) -> Result<Json<UpdateResponse>, 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(&current_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(),
Expand All @@ -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();

Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading