Skip to content

Commit

Permalink
NRF52 SafeFile should not remove / rename files (#5840)
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern authored Jan 13, 2025
1 parent 89a9e0b commit 1c0f43c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/SafeFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
static File openFile(const char *filename, bool fullAtomic)
{
concurrency::LockGuard g(spiLock);
LOG_DEBUG("Opening %s, fullAtomic=%d", filename, fullAtomic);
#ifdef ARCH_NRF52
lfs_assert_failed = false;
return FSCom.open(filename, FILE_O_WRITE);
#endif
if (!fullAtomic)
FSCom.remove(filename); // Nuke the old file to make space (ignore if it !exists)

Expand All @@ -14,7 +19,6 @@ static File openFile(const char *filename, bool fullAtomic)

// clear any previous LFS errors
lfs_assert_failed = false;

return FSCom.open(filenameTmp.c_str(), FILE_O_WRITE);
}

Expand Down Expand Up @@ -57,6 +61,10 @@ bool SafeFile::close()
spiLock->lock();
f.close();
spiLock->unlock();

#ifdef ARCH_NRF52
return true;
#endif
if (!testReadback())
return false;

Expand Down

0 comments on commit 1c0f43c

Please sign in to comment.