OTA Updater better error codes on OOS (#2793)
Fixes #2785. Thanks @donmsmall!
This commit is contained in:
parent
b506c010f7
commit
79568a3e63
1 changed files with 7 additions and 0 deletions
|
|
@ -97,12 +97,18 @@ bool UpdaterClass::begin(size_t size, int command) {
|
|||
_md5 = MD5Builder();
|
||||
|
||||
if (command == U_FLASH) {
|
||||
// Basic sanity, if it's larger than entire FS then it can't possibly succeed
|
||||
if (&_FS_start + size > &_FS_end) {
|
||||
_setError(UPDATE_ERROR_SPACE);
|
||||
return false;
|
||||
}
|
||||
LittleFS.begin();
|
||||
_fp = LittleFS.open("firmware.bin", "w+");
|
||||
if (!_fp) {
|
||||
#ifdef DEBUG_UPDATER
|
||||
DEBUG_UPDATER.println(F("[begin] unable to create file"));
|
||||
#endif
|
||||
_setError(UPDATE_ERROR_SPACE);
|
||||
return false;
|
||||
}
|
||||
updateStartAddress = 0; // Not used
|
||||
|
|
@ -288,6 +294,7 @@ bool UpdaterClass::end(bool evenIfRemaining) {
|
|||
bool UpdaterClass::_writeBuffer() {
|
||||
if (_command == U_FLASH) {
|
||||
if (_bufferLen != _fp.write(_buffer, _bufferLen)) {
|
||||
_setError(UPDATE_ERROR_SPACE);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue