Files
SolarEnergy/central_backend/src/server/devices_api/devices_ota.rs
Pierre HUBERT 665a04c8a0
All checks were successful
continuous-integration/drone/push Build is passing
Update backend code to Rust Edition 2024
2025-03-28 19:25:15 +01:00

22 lines
665 B
Rust

use crate::ota::ota_manager;
use crate::ota::ota_update::OTAPlatform;
use crate::server::custom_error::HttpResult;
use actix_web::{HttpResponse, web};
#[derive(serde::Deserialize)]
pub struct FirmwarePath {
platform: OTAPlatform,
version: semver::Version,
}
/// Download firmware update
pub async fn retrieve_firmware(path: web::Path<FirmwarePath>) -> HttpResult {
if !ota_manager::update_exists(path.platform, &path.version)? {
return Ok(HttpResponse::NotFound().json("The requested firmware was not found!"));
}
let firmware = ota_manager::get_ota_update(path.platform, &path.version)?;
Ok(HttpResponse::Ok().body(firmware))
}