From 3e624dc30471367e0c2c41efdde514eb03772c76 Mon Sep 17 00:00:00 2001 From: Pavel Brychta Date: Wed, 26 Aug 2020 07:16:21 +0200 Subject: [PATCH] Sync s Lorolem - odstraneni varovani ohledne SPIFFS zastarani --- src/SPIFFSEditor.h | 3 ++- src/WebHandlers.cpp | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) 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); + } } }