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:
J. Nick Koston
2026-04-13 13:07:50 -10:00
parent ba2558edf6
commit c26d180325
@@ -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();
}