Skip to content

Commit

Permalink
[tsdb][read_sector_info]: fix flash overwrite when abnormal power loss (
Browse files Browse the repository at this point in the history
  • Loading branch information
Mason-Zhang-X-C authored Oct 6, 2024
1 parent f0af0ee commit 714d615
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/fdb_tsdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,12 @@ static fdb_err_t read_sector_info(fdb_tsdb_t db, uint32_t addr, tsdb_sec_info_t

tsl.addr.index = sector->empty_idx;
while (read_tsl(db, &tsl) == FDB_NO_ERR) {
if (tsl.status == FDB_TSL_UNUSED || tsl.status == FDB_TSL_PRE_WRITE) {
if (tsl.status == FDB_TSL_UNUSED) {
break;
}
sector->end_time = tsl.time;
if (tsl.status != FDB_TSL_PRE_WRITE) {
sector->end_time = tsl.time;
}
sector->end_idx = tsl.addr.index;
sector->empty_idx += LOG_IDX_DATA_SIZE;
sector->empty_data -= FDB_WG_ALIGN(tsl.log_len);
Expand Down

0 comments on commit 714d615

Please sign in to comment.