Repository navigation
WebUI upload refused after a previous upload was cut off - #25367
Merged
Merged
Conversation
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.
Collaborator
|
Well done, this was an old bug, but not severe enough so it didn't motivate anyone to fix it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_erroris cleared only inHandleUploadDone(), and an upload that is cut off never gets there.HandleUploadLoop()returns atif (Web.upload_error) { ... return; }beforeUPLOAD_FILE_STARTresets 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 theUPLOAD_FILE_ABORTEDcall, so its clean-up (Upload aborted,Update.end(),UploadServices(1)) never runs.Updatestays running, and the next upload'sUpdate.begin()fails with "Not enough space", even though the image fits.The change, in
HandleUploadLoop()only:UPLOAD_FILE_START, before the early return, clear the error left by an upload that never reachedHandleUploadDone(), and end anUpdatestill running from it (Update.isRunning()/Update.end(), which both cores have;end()withoutevenIfRemainingresets an incomplete update on both).UPLOAD_FILE_ABORTED. Every request still passesWebAuthenticate(), and only a request whose upload has already started reachesUPLOAD_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:
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) andtasmota(ESP8266, core 2.7.8).Run in QEMU (an ESP32-C3 with emulated Wi-Fi), with the
tasmota32c3-safebootbuild, development with and without this change. The device was on its setup AP at 192.168.4.1. A firmware upload to/u2was cut by killing the client part way, and then the same image was uploaded again: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.