equals for /presets.json instead of indexof

This commit is contained in:
Christian Schwinne 2022-10-24 18:44:11 +02:00 committed by GitHub
parent 92329a8dd0
commit 5ba1ebd525
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,14 +45,14 @@ void handleUpload(AsyncWebServerRequest *request, const String& filename, size_t
request->_tempFile = WLED_FS.open(finalname, "w"); request->_tempFile = WLED_FS.open(finalname, "w");
DEBUG_PRINT("Uploading "); DEBUG_PRINT("Uploading ");
DEBUG_PRINTLN(finalname); DEBUG_PRINTLN(finalname);
if (finalname.indexOf("presets.json") >= 0) presetsModifiedTime = toki.second(); if (finalname.equals("/presets.json") >= 0) 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.indexOf("cfg.json") >= 0) { if (filename.indexOf("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);
} }