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:
parent
cfb6d50844
commit
f9084603de
@ -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;
|
||||||
|
@ -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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user