Skip to content

Commit

Permalink
problème de taille...
Browse files Browse the repository at this point in the history
  • Loading branch information
rene-d committed Feb 24, 2020
1 parent c934511 commit 9b06df8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
static bool sys_update_is_ok = false; // indicates a successful update
static Ticker blink;

extern "C" uint32_t _FS_start;
extern "C" uint32_t _FS_end;

//
static void sys_update_finish(ESP8266WebServer &server, bool finish = false)
{
Expand Down Expand Up @@ -89,7 +92,20 @@ void sys_update_register(ESP8266WebServer &server)
sys_update_is_ok = false;
int command = (upload.filename.indexOf("spiffs.bin") != -1) ? U_FS : U_FLASH;

if (!Update.begin(1024000, command))
// upload.contentLength is NOT the real upload size
uint32_t max_size;
if (command == U_FS)
{
// contentLength is a little above the authorized length
max_size = (uint32_t)&_FS_end - (uint32_t)&_FS_start;
}
else
{
// should be always ok
max_size = upload.contentLength;
}

if (!Update.begin(max_size, command))
{
Serial.println(F("begin error"));
sys_update_finish(server);
Expand Down

1 comment on commit 9b06df8

@rene-d
Copy link
Owner Author

@rene-d rene-d commented on 9b06df8 Feb 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy detected an issue:

Message: Possible binding to all interfaces.

Currently on:

Please sign in to comment.