Fix NRF52 default append write mode of files (#5858)

* Fix NRF52 default append write mode of files

* Inside the lock
This commit is contained in:
Ben Meadors 2025-01-15 06:46:12 -06:00 committed by GitHub
parent fb2c008c89
commit 85de193845
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,7 +9,9 @@ static File openFile(const char *filename, bool fullAtomic)
LOG_DEBUG("Opening %s, fullAtomic=%d", filename, fullAtomic);
#ifdef ARCH_NRF52
lfs_assert_failed = false;
return FSCom.open(filename, FILE_O_WRITE);
File file = FSCom.open(filename, FILE_O_WRITE);
file.seek(0);
return file;
#endif
if (!fullAtomic)
FSCom.remove(filename); // Nuke the old file to make space (ignore if it !exists)
@ -59,6 +61,9 @@ bool SafeFile::close()
return false;
spiLock->lock();
#ifdef ARCH_NRF52
f.truncate();
#endif
f.close();
spiLock->unlock();