This commit is contained in:
Ben Meadors
2025-03-04 06:55:00 -06:00
parent ac3980e98d
commit 661fcd0e77
2 changed files with 20 additions and 4 deletions

View File

@@ -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);
}