mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-03 03:09:59 +00:00
Don't delete contents of /static unless tar is downloaded
This commit is contained in:
parent
063d7a7d81
commit
d5fc905402
@ -689,6 +689,14 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
|||||||
|
|
||||||
res->println("Downloading Meshtastic Web Content...");
|
res->println("Downloading Meshtastic Web Content...");
|
||||||
|
|
||||||
|
WiFiClientSecure *client = new WiFiClientSecure;
|
||||||
|
Stream *streamptr = getTarHTTPClientPtr(client, tarURL, certificate);
|
||||||
|
|
||||||
|
delay(5); // Let other network operations run
|
||||||
|
|
||||||
|
if (streamptr != nullptr) {
|
||||||
|
DEBUG_MSG("Connection to content server ... success!\n");
|
||||||
|
|
||||||
File root = SPIFFS.open("/");
|
File root = SPIFFS.open("/");
|
||||||
File file = root.openNextFile();
|
File file = root.openNextFile();
|
||||||
|
|
||||||
@ -703,12 +711,7 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
|||||||
file = root.openNextFile();
|
file = root.openNextFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// return;
|
delay(5); // Let other network operations run
|
||||||
|
|
||||||
WiFiClientSecure *client = new WiFiClientSecure;
|
|
||||||
Stream *streamptr = getTarHTTPClientPtr(client, tarURL, certificate);
|
|
||||||
|
|
||||||
if (streamptr != nullptr) {
|
|
||||||
|
|
||||||
TarUnpacker *TARUnpacker = new TarUnpacker();
|
TarUnpacker *TARUnpacker = new TarUnpacker();
|
||||||
TARUnpacker->haltOnError(false); // stop on fail (manual restart/reset required)
|
TARUnpacker->haltOnError(false); // stop on fail (manual restart/reset required)
|
||||||
@ -731,7 +734,10 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!TARUnpacker->tarStreamExpander(streamptr, streamSize, SPIFFS, "/static")) {
|
if (!TARUnpacker->tarStreamExpander(streamptr, streamSize, SPIFFS, "/static")) {
|
||||||
|
res->printf("tarStreamExpander failed with return code #%d\n", TARUnpacker->tarGzGetError());
|
||||||
Serial.printf("tarStreamExpander failed with return code #%d\n", TARUnpacker->tarGzGetError());
|
Serial.printf("tarStreamExpander failed with return code #%d\n", TARUnpacker->tarGzGetError());
|
||||||
|
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
// print leftover bytes if any (probably zero-fill from the server)
|
// print leftover bytes if any (probably zero-fill from the server)
|
||||||
while (http.connected()) {
|
while (http.connected()) {
|
||||||
@ -744,7 +750,9 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
res->printf("Failed to establish http connection\n");
|
||||||
Serial.println("Failed to establish http connection");
|
Serial.println("Failed to establish http connection");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
res->println("<a href=/>Done</a>");
|
res->println("<a href=/>Done</a>");
|
||||||
|
Loading…
Reference in New Issue
Block a user