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

Fix NRF52 default append write mode of files #5858

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Changes from 2 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
7 changes: 6 additions & 1 deletion src/SafeFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -57,6 +59,9 @@ bool SafeFile::close()
{
if (!f)
return false;
#ifdef ARCH_NRF52
f.truncate();
#endif

spiLock->lock();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this lock happen before the truncate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Pushed the change

f.close();
Expand Down
Loading