Unverified Commit c13bb1ec authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

Make multiple SDFS/LittleFS.begin calls noops (#262)

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().
parent c777dd16
......@@ -176,6 +176,9 @@ public:
}
bool begin() override {
if (_mounted) {
return true;
}
if (_size <= 0) {
DEBUGV("LittleFS size is <= zero");
return false;
......
......@@ -148,7 +148,7 @@ public:
bool begin() override {
if (_mounted) {
end();
return true;
}
_mounted = _fs.begin(_cfg._csPin, _cfg._spiSettings);
if (!_mounted && _cfg._autoFormat) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment