mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-21 18:52:36 +10:00
XModemAdapter: ensure file truncation before receiving and add isBusy() method to prevent concurrent writes
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user