XModemAdapter: ensure file truncation before receiving and add isBusy() method to prevent concurrent writes

This commit is contained in:
Ben Meadors
2026-05-12 15:38:56 -05:00
parent 7ff6641f97
commit d9cb74e4dd
2 changed files with 20 additions and 1 deletions
+6
View File
@@ -52,6 +52,12 @@ class XModemAdapter
meshtastic_XModem getForPhone();
void resetForPhone();
// True while a file is being received from or transmitted to the phone.
// Callers (e.g. NodeDB::saveNodeDatabaseToDisk) consult this to avoid
// opening the same on-disk file for write in parallel, which races our
// long-lived xmodem `file` handle and ends up producing a 0-byte file.
bool isBusy() const { return isReceiving || isTransmitting; }
private:
bool isReceiving = false;
bool isTransmitting = false;