Skip to content

Commit 2e4563c

Browse files
Receiving no data in Updater is an error (#7729)
Fixes #7721 by adding a new error code for when Update::end is called without any progress at all being made (i.e. no data actually ::write() to the Update object.
1 parent cfd9a34 commit 2e4563c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Diff for: cores/esp8266/Updater.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ bool UpdaterClass::end(bool evenIfRemaining){
203203
return false;
204204
}
205205

206+
// Updating w/o any data is an error we detect here
207+
if (!progress()) {
208+
_setError(UPDATE_ERROR_NO_DATA);
209+
}
210+
206211
if(hasError() || (!isFinished() && !evenIfRemaining)){
207212
#ifdef DEBUG_UPDATER
208213
DEBUG_UPDATER.printf_P(PSTR("premature end: res:%u, pos:%zu/%zu\n"), getError(), progress(), _size);
@@ -551,6 +556,8 @@ void UpdaterClass::printError(Print &out){
551556
out.println(F("Bad Size Given"));
552557
} else if(_error == UPDATE_ERROR_STREAM){
553558
out.println(F("Stream Read Timeout"));
559+
} else if(_error == UPDATE_ERROR_NO_DATA){
560+
out.println(F("No data supplied"));
554561
} else if(_error == UPDATE_ERROR_MD5){
555562
out.printf_P(PSTR("MD5 Failed: expected:%s, calculated:%s\n"), _target_md5.c_str(), _md5.toString().c_str());
556563
} else if(_error == UPDATE_ERROR_SIGN){

Diff for: cores/esp8266/Updater.h

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define UPDATE_ERROR_MAGIC_BYTE (10)
2020
#define UPDATE_ERROR_BOOTSTRAP (11)
2121
#define UPDATE_ERROR_SIGN (12)
22+
#define UPDATE_ERROR_NO_DATA (13)
2223

2324
#define U_FLASH 0
2425
#define U_FS 100

0 commit comments

Comments
 (0)