mirror of
https://github.com/esphome/esphome.git
synced 2026-09-19 11:08:38 +00:00
Emit OTA_ABORT state when tearing down a stale session on retry
Addresses Copilot review suggestion on #15720: when the handler aborts a previously interrupted OTA session because a new upload arrived, also fire the OTA_ABORT state notification so user-facing on_abort: automations and other OTA state listeners observe the teardown. Without this, the abort would be silent to listeners (distinct from OTA_ERROR, which signals a failed session rather than a superseded one).
This commit is contained in:
@@ -126,6 +126,10 @@ void OTARequestHandler::handleUpload(AsyncWebServerRequest *request, const Platf
|
||||
if (this->ota_backend_) {
|
||||
ESP_LOGW(TAG, "New OTA upload received while previous session was still open; aborting previous session");
|
||||
this->ota_backend_->abort();
|
||||
#ifdef USE_OTA_STATE_LISTENER
|
||||
// Notify listeners that the previous session was aborted before the new one starts.
|
||||
this->parent_->notify_state_deferred_(ota::OTA_ABORT, 0.0f, 0);
|
||||
#endif
|
||||
this->ota_backend_.reset();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user