Can delete an OTA update
This commit is contained in:
		@@ -195,7 +195,10 @@ pub async fn secure_server(energy_actor: EnergyActorAddr) -> anyhow::Result<()>
 | 
			
		||||
                "/web_api/ota/{platform}/{version}",
 | 
			
		||||
                web::get().to(ota_controller::download_firmware),
 | 
			
		||||
            )
 | 
			
		||||
            // TODO : delete an OTA file
 | 
			
		||||
            .route(
 | 
			
		||||
                "/web_api/ota/{platform}/{version}",
 | 
			
		||||
                web::delete().to(ota_controller::delete_update),
 | 
			
		||||
            )
 | 
			
		||||
            .route("/web_api/ota", web::get().to(ota_controller::list_all_ota))
 | 
			
		||||
            .route(
 | 
			
		||||
                "/web_api/ota/{platform}",
 | 
			
		||||
 
 | 
			
		||||
@@ -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()?))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user