Skip to content

Commit

Permalink
NRF52 - Remove file totally before opening write (meshtastic#5916)
Browse files Browse the repository at this point in the history
* Remove prefs first

* Remove file first

* Remove truncate

* No longer needed

* Missed a param

* That wasn't supposed to be there

* Remove vestigal lfs assert

* Durr
  • Loading branch information
thebentern authored Jan 24, 2025
1 parent 3b40fe9 commit 0d86088
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/SafeFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ static File openFile(const char *filename, bool fullAtomic)
concurrency::LockGuard g(spiLock);
LOG_DEBUG("Opening %s, fullAtomic=%d", filename, fullAtomic);
#ifdef ARCH_NRF52
File file = FSCom.open(filename, FILE_O_WRITE);
file.seek(0);
return file;
FSCom.remove(filename);
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 Down Expand Up @@ -59,9 +58,6 @@ bool SafeFile::close()
return false;

spiLock->lock();
#ifdef ARCH_NRF52
f.truncate();
#endif
f.close();
spiLock->unlock();

Expand Down

0 comments on commit 0d86088

Please sign in to comment.