mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-21 12:38:34 +00:00
Locks
This commit is contained in:
parent
ac3980e98d
commit
661fcd0e77
@ -7,16 +7,23 @@ static File openFile(const char *filename, bool fullAtomic)
|
||||
{
|
||||
concurrency::LockGuard g(spiLock);
|
||||
LOG_DEBUG("Opening %s, fullAtomic=%d", filename, fullAtomic);
|
||||
|
||||
#ifdef ARCH_NRF52
|
||||
FSCom.remove(filename);
|
||||
return FSCom.open(filename, FILE_O_WRITE);
|
||||
#endif
|
||||
if (!fullAtomic)
|
||||
if (!fullAtomic) {
|
||||
FSCom.remove(filename); // Nuke the old file to make space (ignore if it !exists)
|
||||
}
|
||||
|
||||
String filenameTmp = filename;
|
||||
filenameTmp += ".tmp";
|
||||
|
||||
// If we are doing a full atomic write, remove the old tmp file now
|
||||
if (fullAtomic) {
|
||||
FSCom.remove(filename);
|
||||
}
|
||||
|
||||
// clear any previous LFS errors
|
||||
return FSCom.open(filenameTmp.c_str(), FILE_O_WRITE);
|
||||
}
|
||||
|
@ -1243,7 +1243,12 @@ bool NodeDB::saveToDiskNoRetry(int saveWhat)
|
||||
config.has_bluetooth = true;
|
||||
config.has_security = true;
|
||||
|
||||
success &= saveProto(configFileName, meshtastic_LocalConfig_size, &meshtastic_LocalConfig_msg, &config);
|
||||
size_t configSize;
|
||||
pb_get_encoded_size(&configSize, meshtastic_LocalConfig_fields, &config);
|
||||
LOG_DEBUG("Saving config version %d", config.version);
|
||||
spiLock->lock();
|
||||
success &= saveProto(configFileName, configSize, &meshtastic_LocalConfig_msg, &config);
|
||||
spiLock->unlock();
|
||||
}
|
||||
|
||||
if (saveWhat & SEGMENT_MODULECONFIG) {
|
||||
@ -1259,9 +1264,13 @@ bool NodeDB::saveToDiskNoRetry(int saveWhat)
|
||||
moduleConfig.has_ambient_lighting = true;
|
||||
moduleConfig.has_audio = true;
|
||||
moduleConfig.has_paxcounter = true;
|
||||
LOG_DEBUG("Saving moduleConfig version %d", moduleConfig.version);
|
||||
|
||||
success &=
|
||||
saveProto(moduleConfigFileName, meshtastic_LocalModuleConfig_size, &meshtastic_LocalModuleConfig_msg, &moduleConfig);
|
||||
size_t moduleConfigSize;
|
||||
pb_get_encoded_size(&moduleConfigSize, meshtastic_LocalModuleConfig_fields, &moduleConfig);
|
||||
spiLock->lock();
|
||||
success &= saveProto(moduleConfigFileName, moduleConfigSize, &meshtastic_LocalModuleConfig_msg, &moduleConfig);
|
||||
spiLock->unlock();
|
||||
}
|
||||
|
||||
if (saveWhat & SEGMENT_CHANNELS) {
|
||||
|
Loading…
Reference in New Issue
Block a user