fix not writing version number into the file

pull/6932/head
paul-szczepanek-arm 2018-05-22 11:45:38 +01:00
parent 62ba220100
commit 7d916a9997
1 changed files with 8 additions and 9 deletions

View File

@ -267,16 +267,15 @@ void FileSecurityDb::set_entry_peer_sign_counter(
/* saving and loading from nvm */
void FileSecurityDb::restore() {
fseek(_db_file, DB_OFFSET_RESTORE, SEEK_SET);
/* restore if requested */
bool restore_toggle;
if (fread(&restore_toggle, sizeof(bool), 1, _db_file) == 1) {
if (!restore_toggle) {
erase_db_file(_db_file);
return;
}
bool restore_toggle = false;
db_read(&restore_toggle, DB_OFFSET_RESTORE);
if (!restore_toggle) {
erase_db_file(_db_file);
db_write(&DB_VERSION, DB_OFFSET_VERSION);
return;
}
db_read(&_local_identity, DB_OFFSET_LOCAL_IDENTITY);