diff --git a/src/SPIFFSEditor.h b/src/SPIFFSEditor.h index 3586429..d3b959f 100644 --- a/src/SPIFFSEditor.h +++ b/src/SPIFFSEditor.h @@ -13,7 +13,8 @@ class SPIFFSEditor: public AsyncWebHandler { #ifdef ESP32 SPIFFSEditor(const fs::FS& fs, const String& username=String(), const String& password=String()); #else - SPIFFSEditor(const String& username=String(), const String& password=String(), const fs::FS& fs=SPIFFS); + //SPIFFSEditor(const String& username=String(), const String& password=String(), const fs::FS& fs=SPIFFS); + SPIFFSEditor(const String& username, const String& password, const fs::FS& fs); // do not show warning that SPIFFS has been deprecated #endif virtual bool canHandle(AsyncWebServerRequest *request) override final; virtual void handleRequest(AsyncWebServerRequest *request) override final; diff --git a/src/WebHandlers.cpp b/src/WebHandlers.cpp index 952d65e..8e87ff1 100644 --- a/src/WebHandlers.cpp +++ b/src/WebHandlers.cpp @@ -146,18 +146,26 @@ bool AsyncStaticWebHandler::_fileExists(AsyncWebServerRequest *request, const St String gzip = path + F(".gz"); if (_gzipFirst) { - request->_tempFile = _fs.open(gzip, fs::FileOpenMode::read); - gzipFound = FILE_IS_REAL(request->_tempFile); + if (_fs.exists(gzip)) { + request->_tempFile = _fs.open(gzip, fs::FileOpenMode::read); + gzipFound = FILE_IS_REAL(request->_tempFile); + } if (!gzipFound){ + if (_fs.exists(path)) { request->_tempFile = _fs.open(path, fs::FileOpenMode::read); fileFound = FILE_IS_REAL(request->_tempFile); + } } } else { - request->_tempFile = _fs.open(path, fs::FileOpenMode::read); - fileFound = FILE_IS_REAL(request->_tempFile); + if (_fs.exists(path)) { + request->_tempFile = _fs.open(path, fs::FileOpenMode::read); + fileFound = FILE_IS_REAL(request->_tempFile); + } if (!fileFound){ + if (_fs.exists(gzip)) { request->_tempFile = _fs.open(gzip, fs::FileOpenMode::read); gzipFound = FILE_IS_REAL(request->_tempFile); + } } }