Sync s Lorolem - odstraneni varovani ohledne SPIFFS zastarani

This commit is contained in:
Pavel Brychta 2020-08-26 07:16:21 +02:00
parent c75c331ef5
commit 3e624dc304
2 changed files with 14 additions and 5 deletions

View File

@ -13,7 +13,8 @@ class SPIFFSEditor: public AsyncWebHandler {
#ifdef ESP32 #ifdef ESP32
SPIFFSEditor(const fs::FS& fs, const String& username=String(), const String& password=String()); SPIFFSEditor(const fs::FS& fs, const String& username=String(), const String& password=String());
#else #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 #endif
virtual bool canHandle(AsyncWebServerRequest *request) override final; virtual bool canHandle(AsyncWebServerRequest *request) override final;
virtual void handleRequest(AsyncWebServerRequest *request) override final; virtual void handleRequest(AsyncWebServerRequest *request) override final;

View File

@ -146,20 +146,28 @@ bool AsyncStaticWebHandler::_fileExists(AsyncWebServerRequest *request, const St
String gzip = path + F(".gz"); String gzip = path + F(".gz");
if (_gzipFirst) { if (_gzipFirst) {
if (_fs.exists(gzip)) {
request->_tempFile = _fs.open(gzip, fs::FileOpenMode::read); request->_tempFile = _fs.open(gzip, fs::FileOpenMode::read);
gzipFound = FILE_IS_REAL(request->_tempFile); gzipFound = FILE_IS_REAL(request->_tempFile);
}
if (!gzipFound){ if (!gzipFound){
if (_fs.exists(path)) {
request->_tempFile = _fs.open(path, fs::FileOpenMode::read); request->_tempFile = _fs.open(path, fs::FileOpenMode::read);
fileFound = FILE_IS_REAL(request->_tempFile); fileFound = FILE_IS_REAL(request->_tempFile);
} }
}
} else { } else {
if (_fs.exists(path)) {
request->_tempFile = _fs.open(path, fs::FileOpenMode::read); request->_tempFile = _fs.open(path, fs::FileOpenMode::read);
fileFound = FILE_IS_REAL(request->_tempFile); fileFound = FILE_IS_REAL(request->_tempFile);
}
if (!fileFound){ if (!fileFound){
if (_fs.exists(gzip)) {
request->_tempFile = _fs.open(gzip, fs::FileOpenMode::read); request->_tempFile = _fs.open(gzip, fs::FileOpenMode::read);
gzipFound = FILE_IS_REAL(request->_tempFile); gzipFound = FILE_IS_REAL(request->_tempFile);
} }
} }
}
bool found = fileFound || gzipFound; bool found = fileFound || gzipFound;