Robust contacts - backup first before saving and fallback to backup file#1447
Open
weebl2000 wants to merge 3 commits intomeshcore-dev:devfrom
Open
Robust contacts - backup first before saving and fallback to backup file#1447weebl2000 wants to merge 3 commits intomeshcore-dev:devfrom
weebl2000 wants to merge 3 commits intomeshcore-dev:devfrom
Conversation
3dd2cef to
ad26168
Compare
9778b43 to
06dc6f5
Compare
Contributor
Author
|
I think what actually caused the contacts to miss in the first place was the nodeinfo files that were written regardless of auto-add contacts. |
06dc6f5 to
c16b3be
Compare
The fs->remove("/contacts3.bak") before the rename sequence creates a
vulnerability window: if power is lost right after removing the backup
but before the rename completes, both the backup and primary file could
be lost. The remove is unnecessary since rename() on both SPIFFS and
LittleFS replaces the target if it already exists.
c16b3be to
8266d35
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: Contacts sometimes partially disappear on Heltec v4 and Heltec Wireless Tracker v1.2. This is likely caused by power loss or reset during a direct overwrite of the contacts file.
Solution: Atomic-style write pattern for
saveContacts:/contacts3.tmp)/contacts3→/contacts3.bak/contacts3.tmp→/contacts3/contacts3.bak(no longer needed until next save)If the write fails mid-save, the
.tmpfile is removed and the original contacts file is left untouched.On load, if
/contacts3is missing or empty,loadContactsfalls back to/contacts3.bakautomatically. This covers the edge case where power is lost between steps 3 and 4.Platform guard: Only enabled on devices with sufficient flash for the temporary file (~2x contacts storage during save). Disabled on NRF52 unless
EXTRAFSorQSPIFLASHis defined.Build firmware: Build from this branch