Skip to content

Commit

Permalink
Receiving no data in Updater is an error (#7729)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
earlephilhower committed Dec 1, 2020
1 parent cfd9a34 commit 2e4563c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cores/esp8266/Updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ bool UpdaterClass::end(bool evenIfRemaining){
return false;
}

// Updating w/o any data is an error we detect here
if (!progress()) {
_setError(UPDATE_ERROR_NO_DATA);
}

if(hasError() || (!isFinished() && !evenIfRemaining)){
#ifdef DEBUG_UPDATER
DEBUG_UPDATER.printf_P(PSTR("premature end: res:%u, pos:%zu/%zu\n"), getError(), progress(), _size);
Expand Down Expand Up @@ -551,6 +556,8 @@ void UpdaterClass::printError(Print &out){
out.println(F("Bad Size Given"));
} else if(_error == UPDATE_ERROR_STREAM){
out.println(F("Stream Read Timeout"));
} else if(_error == UPDATE_ERROR_NO_DATA){
out.println(F("No data supplied"));
} else if(_error == UPDATE_ERROR_MD5){
out.printf_P(PSTR("MD5 Failed: expected:%s, calculated:%s\n"), _target_md5.c_str(), _md5.toString().c_str());
} else if(_error == UPDATE_ERROR_SIGN){
Expand Down
1 change: 1 addition & 0 deletions cores/esp8266/Updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define UPDATE_ERROR_MAGIC_BYTE (10)
#define UPDATE_ERROR_BOOTSTRAP (11)
#define UPDATE_ERROR_SIGN (12)
#define UPDATE_ERROR_NO_DATA (13)

#define U_FLASH 0
#define U_FS 100
Expand Down

0 comments on commit 2e4563c

Please sign in to comment.