From d9a2f155fc44362f9e7380595d14fa0ae48a5640 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Sat, 28 Nov 2020 11:39:36 -0800 Subject: [PATCH] Receiving no data in Updater is an error 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. --- cores/esp8266/Updater.cpp | 7 +++++++ cores/esp8266/Updater.h | 1 + 2 files changed, 8 insertions(+) diff --git a/cores/esp8266/Updater.cpp b/cores/esp8266/Updater.cpp index b2e92978eb..d9d468765a 100644 --- a/cores/esp8266/Updater.cpp +++ b/cores/esp8266/Updater.cpp @@ -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); @@ -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){ diff --git a/cores/esp8266/Updater.h b/cores/esp8266/Updater.h index 30c4a0071f..14a4a3baa9 100644 --- a/cores/esp8266/Updater.h +++ b/cores/esp8266/Updater.h @@ -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 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy