Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NRF52 - Remove file totally before opening write #5916

Merged
merged 9 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/SafeFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ 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;
lfs_assert_failed = false;
thebentern marked this conversation as resolved.
Show resolved Hide resolved
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 +59,6 @@ bool SafeFile::close()
return false;

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

Expand Down
1 change: 0 additions & 1 deletion src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,6 @@ bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_
bool fullAtomic)
{
bool okay = false;
#ifdef FSCom
thebentern marked this conversation as resolved.
Show resolved Hide resolved
auto f = SafeFile(filename, fullAtomic);

LOG_INFO("Save %s", filename);
Expand Down
Loading