Merge branch 'master' into 2264-feature-check-for-low-heap-before-adding-to-nodedb-was-reboot-loop-heap-too-low

This commit is contained in:
Thomas Göttgens 2023-04-14 19:56:01 +02:00 committed by GitHub
commit a30c07e6b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 2 deletions

View File

@ -34,6 +34,7 @@ bool copyFile(const char *from, const char *to)
f2.write(cbuffer, i); f2.write(cbuffer, i);
} }
f2.flush();
f2.close(); f2.close();
f1.close(); f1.close();
return true; return true;

View File

@ -490,6 +490,7 @@ bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_
} else { } else {
okay = true; okay = true;
} }
f.flush();
f.close(); f.close();
// brief window of risk here ;-) // brief window of risk here ;-)

View File

@ -234,15 +234,18 @@ void htmlDeleteDir(const char *dirname)
while (file) { while (file) {
if (file.isDirectory() && !String(file.name()).endsWith(".")) { if (file.isDirectory() && !String(file.name()).endsWith(".")) {
htmlDeleteDir(file.name()); htmlDeleteDir(file.name());
file.flush();
file.close(); file.close();
} else { } else {
String fileName = String(file.name()); String fileName = String(file.name());
file.flush();
file.close(); file.close();
LOG_DEBUG(" %s\n", fileName.c_str()); LOG_DEBUG(" %s\n", fileName.c_str());
FSCom.remove(fileName); FSCom.remove(fileName);
} }
file = root.openNextFile(); file = root.openNextFile();
} }
root.flush();
root.close(); root.close();
} }
@ -521,7 +524,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
std::string pathname = "/static/" + filename; std::string pathname = "/static/" + filename;
// Create a new file to stream the data into // Create a new file to stream the data into
File file = FSCom.open(pathname.c_str(), "w"); File file = FSCom.open(pathname.c_str(), FILE_O_WRITE);
size_t fileLength = 0; size_t fileLength = 0;
didwrite = true; didwrite = true;
@ -536,6 +539,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
// Abort the transfer if there is less than 50k space left on the filesystem. // Abort the transfer if there is less than 50k space left on the filesystem.
if (FSCom.totalBytes() - FSCom.usedBytes() < 51200) { if (FSCom.totalBytes() - FSCom.usedBytes() < 51200) {
file.flush();
file.close(); file.close();
res->println("<p>Write aborted! Reserving 50k on filesystem.</p>"); res->println("<p>Write aborted! Reserving 50k on filesystem.</p>");
@ -553,6 +557,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
} }
// enableLoopWDT(); // enableLoopWDT();
file.flush();
file.close(); file.close();
res->printf("<p>Saved %d bytes to %s</p>", (int)fileLength, pathname.c_str()); res->printf("<p>Saved %d bytes to %s</p>", (int)fileLength, pathname.c_str());
} }

View File

@ -226,7 +226,7 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
} else { } else {
LOG_ERROR("File write failed\n"); LOG_ERROR("File write failed\n");
} }
fileToWrite.flush();
fileToWrite.close(); fileToWrite.close();
} }
@ -275,6 +275,7 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
// TODO: If quotes are found in the payload, it has to be escaped. // TODO: If quotes are found in the payload, it has to be escaped.
fileToAppend.printf("\"%s\"\n", p.payload.bytes); fileToAppend.printf("\"%s\"\n", p.payload.bytes);
fileToAppend.flush();
fileToAppend.close(); fileToAppend.close();
return 1; return 1;

View File

@ -142,12 +142,14 @@ void XModemAdapter::handlePacket(meshtastic_XModem xmodemPacket)
case meshtastic_XModem_Control_EOT: case meshtastic_XModem_Control_EOT:
// End of transmission // End of transmission
sendControl(meshtastic_XModem_Control_ACK); sendControl(meshtastic_XModem_Control_ACK);
file.flush();
file.close(); file.close();
isReceiving = false; isReceiving = false;
break; break;
case meshtastic_XModem_Control_CAN: case meshtastic_XModem_Control_CAN:
// Cancel transmission and remove file // Cancel transmission and remove file
sendControl(meshtastic_XModem_Control_ACK); sendControl(meshtastic_XModem_Control_ACK);
file.flush();
file.close(); file.close();
FSCom.remove(filename); FSCom.remove(filename);
isReceiving = false; isReceiving = false;