Merge pull request #2850 from ahadcove/fix/restoring_cfg_json
fix: restoring cfg.json #2847
This commit is contained in:
commit
779fd78091
@ -39,20 +39,20 @@ void handleUpload(AsyncWebServerRequest *request, const String& filename, size_t
|
|||||||
if (!index) {
|
if (!index) {
|
||||||
String finalname = filename;
|
String finalname = filename;
|
||||||
if (finalname.charAt(0) != '/') {
|
if (finalname.charAt(0) != '/') {
|
||||||
finalname = "/" + finalname; // prepend slash if missing
|
finalname = '/' + finalname; // prepend slash if missing
|
||||||
}
|
}
|
||||||
|
|
||||||
request->_tempFile = WLED_FS.open(finalname, "w");
|
request->_tempFile = WLED_FS.open(finalname, "w");
|
||||||
DEBUG_PRINT("Uploading ");
|
DEBUG_PRINT(F("Uploading "));
|
||||||
DEBUG_PRINTLN(finalname);
|
DEBUG_PRINTLN(finalname);
|
||||||
if (finalname == "/presets.json") presetsModifiedTime = toki.second();
|
if (finalname.equals("/presets.json")) presetsModifiedTime = toki.second();
|
||||||
}
|
}
|
||||||
if (len) {
|
if (len) {
|
||||||
request->_tempFile.write(data,len);
|
request->_tempFile.write(data,len);
|
||||||
}
|
}
|
||||||
if (final) {
|
if (final) {
|
||||||
request->_tempFile.close();
|
request->_tempFile.close();
|
||||||
if (filename == "/cfg.json") {
|
if (filename.indexOf(F("cfg.json")) >= 0) { // check for filename with or without slash
|
||||||
doReboot = true;
|
doReboot = true;
|
||||||
request->send(200, "text/plain", F("Configuration restore successful.\nRebooting..."));
|
request->send(200, "text/plain", F("Configuration restore successful.\nRebooting..."));
|
||||||
} else
|
} else
|
||||||
@ -618,4 +618,4 @@ void serveSettings(AsyncWebServerRequest* request, bool post)
|
|||||||
response->addHeader(FPSTR(s_content_enc),"gzip");
|
response->addHeader(FPSTR(s_content_enc),"gzip");
|
||||||
setStaticContentCacheHeaders(response);
|
setStaticContentCacheHeaders(response);
|
||||||
request->send(response);
|
request->send(response);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user