Skip to content

WebUI upload refused after a previous upload was cut off - #25367

Merged
arendst merged 2 commits into
arendst:developmentfrom
adamsthws:fix-upload-error-latch
Dec 2, 2026
Merged

arendst merged 2 commits into
arendst:developmentfrom
adamsthws:fix-upload-error-latch

Conversation

@adamsthws

Copy link
Copy Markdown
Contributor

Description:

After an upload is cut off part way, the next upload (firmware, or a file in Manage File system) is refused. This needs no restart in between.

Web.upload_error is cleared only in HandleUploadDone(), and an upload that is cut off never gets there. HandleUploadLoop() returns at if (Web.upload_error) { ... return; } before UPLOAD_FILE_START resets the error, so the next upload is refused with the old error. That refusal does clear it, so the upload after that one works again.

When the device loses its Wi-Fi during an upload, it gets worse. Wi-Fi lost, WiFi.localIP() no longer matches the Referer. HttpCheckPriviledgedAccess(false) then refuses the UPLOAD_FILE_ABORTED call, so its clean-up (Upload aborted, Update.end(), UploadServices(1)) never runs. Update stays running, and the next upload's Update.begin() fails with "Not enough space", even though the image fits.

The change, in HandleUploadLoop() only:

  • At UPLOAD_FILE_START, before the early return, clear the error left by an upload that never reached HandleUploadDone(), and end an Update still running from it (Update.isRunning() / Update.end(), which both cores have; end() without evenIfRemaining resets an incomplete update on both).
  • The Referer check no longer applies to UPLOAD_FILE_ABORTED. Every request still passes WebAuthenticate(), and only a request whose upload has already started reaches UPLOAD_FILE_ABORTED. The clean-up stops that upload; it starts nothing.

This is the same kind of latch as #20340, which fixed it for the "No file selected" case.

Related issue (if applicable): none found

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works with Tasmota core ESP8266 V.2.7.8 (compiles without warnings; not run on an ESP8266)
  • The code change is tested and works with Tasmota core ESP32 V.3.3.12-3 from Platform 2026.11.51
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

Testing

Built without warnings with pioarduino 6.2.0: tasmota32c3-safeboot (core 3.3.12-3, platform 2026.11.51) and tasmota (ESP8266, core 2.7.8).

Run in QEMU (an ESP32-C3 with emulated Wi-Fi), with the tasmota32c3-safeboot build, development with and without this change. The device was on its setup AP at 192.168.4.1. A firmware upload to /u2 was cut by killing the client part way, and then the same image was uploaded again:

upload cut part way next upload the one after
development - Upload Failed: Upload aborted Upload Successful
with this change - Upload Successful

I did not run the case where the Wi-Fi is lost during the upload in the same way, because the device was on its setup AP, where the Referer check does not apply. Before this change, a device on its home Wi-Fi that lost the network during an upload to the safeboot refused the next upload with "Not enough space", although the image fitted. The upload after that one was taken.

adamsthws and others added 2 commits December 1, 2026 01:23
An upload cut part way left Web.upload_error set, as only HandleUploadDone
clears it and a cut upload never gets there. The next upload then returned
at the early `if (Web.upload_error)` check, before UPLOAD_FILE_START reset
it, and was refused with the old error.

When the device lost its Wi-Fi during the upload, HttpCheckPriviledgedAccess
also refused the UPLOAD_FILE_ABORTED call, as the Referer no longer matched
the local IP, so Update.end() never ran. The next upload's Update.begin()
then failed with "Not enough space".

Clear the error and end an update still begun at UPLOAD_FILE_START, before
the early return, and run the abort clean-up without the Referer check.
@arendst
arendst merged commit 36d8a19 into arendst:development Dec 2, 2026
68 checks passed
@s-hadinger

Copy link
Copy Markdown
Collaborator

Well done, this was an old bug, but not severe enough so it didn't motivate anyone to fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants