Can delete an OTA update

This commit is contained in:
2024-10-08 22:22:57 +02:00
parent 2e4a2b68dd
commit eafa8e6a4b
5 changed files with 79 additions and 8 deletions

View File

@ -74,6 +74,17 @@ pub async fn download_firmware(path: web::Path<SpecificOTAVersionPath>) -> HttpR
.body(firmware))
}
/// Delete an uploaded firmware update
pub async fn delete_update(path: web::Path<SpecificOTAVersionPath>) -> HttpResult {
if !ota_manager::update_exists(path.platform, &path.version)? {
return Ok(HttpResponse::NotFound().json("The requested update was not found!"));
}
ota_manager::delete_update(path.platform, &path.version)?;
Ok(HttpResponse::Accepted().finish())
}
/// Get the list of all OTA updates
pub async fn list_all_ota() -> HttpResult {
Ok(HttpResponse::Ok().json(ota_manager::get_all_ota_updates()?))