1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Make multiple FS begin calls noops() SDFS/LittleFS (#8235)

When LittleFS.begin() or SDFS.begin() is called after the filesystem is
already mounted, don't unmount/remount.  When an unmount happens, all old
Files become invalid (but the core doesn't know this), so you would end
up with random crashes in FS code.

Now, check for _mounted, and if so just return immediately from begin().
This mimics the original SPIFFS code.

Fixes https://github.com/earlephilhower/ESP8266Audio/issues/407
This commit is contained in:
Earle F. Philhower, III 2021-07-26 12:58:40 -07:00 committed by GitHub
parent cfb6d50844
commit f9084603de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -183,6 +183,9 @@ public:
} }
bool begin() override { bool begin() override {
if (_mounted) {
return true;
}
if ((_blockSize <= 0) || (_size <= 0)) { if ((_blockSize <= 0) || (_size <= 0)) {
DEBUGV("LittleFS size is <= zero"); DEBUGV("LittleFS size is <= zero");
return false; return false;

View File

@ -149,7 +149,7 @@ public:
bool begin() override { bool begin() override {
if (_mounted) { if (_mounted) {
end(); return true;
} }
_mounted = _fs.begin(_cfg._csPin, _cfg._spiSettings); _mounted = _fs.begin(_cfg._csPin, _cfg._spiSettings);
if (!_mounted && _cfg._autoFormat) { if (!_mounted && _cfg._autoFormat) {