Fix bug where preferences.json was never closed
This commit is contained in:
parent
2532230c39
commit
64b1b86047
|
@ -92,14 +92,16 @@ namespace msc {
|
|||
}
|
||||
|
||||
void print() {
|
||||
File file;
|
||||
FatFile rdir;
|
||||
rdir.open("/");
|
||||
Serial.println("Available files:");
|
||||
|
||||
// Open next file in root.
|
||||
// Warning, openNext starts at the current directory position
|
||||
// so a rewind of the directory may be required.
|
||||
while(file.openNext(&rdir, O_RDONLY)) {
|
||||
// Close file(s)
|
||||
if (file.isOpen()) file.close();
|
||||
while (!file_stack.empty()) file_stack.pop();
|
||||
|
||||
SdFile root;
|
||||
root.open("/");
|
||||
|
||||
while ( file.openNext(&root, O_RDONLY) ) {
|
||||
file.printFileSize(&Serial);
|
||||
Serial.write(' ');
|
||||
file.printName(&Serial);
|
||||
|
|
|
@ -101,6 +101,7 @@ namespace preferences {
|
|||
// Open the file and read it into a buffer
|
||||
if (!msc::open(PREFERENCES_PATH), false) return;
|
||||
msc::read(buffer, JSON_SIZE);
|
||||
msc::close();
|
||||
|
||||
// Deserialize the JSON document
|
||||
DeserializationError error = deserializeJson(config_doc, buffer);
|
||||
|
|
Loading…
Reference in New Issue