Skip to content

Commit 714d615

Browse files
[tsdb][read_sector_info]: fix flash overwrite when abnormal power loss (#316)
1 parent f0af0ee commit 714d615

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/fdb_tsdb.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,12 @@ static fdb_err_t read_sector_info(fdb_tsdb_t db, uint32_t addr, tsdb_sec_info_t
238238

239239
tsl.addr.index = sector->empty_idx;
240240
while (read_tsl(db, &tsl) == FDB_NO_ERR) {
241-
if (tsl.status == FDB_TSL_UNUSED || tsl.status == FDB_TSL_PRE_WRITE) {
241+
if (tsl.status == FDB_TSL_UNUSED) {
242242
break;
243243
}
244-
sector->end_time = tsl.time;
244+
if (tsl.status != FDB_TSL_PRE_WRITE) {
245+
sector->end_time = tsl.time;
246+
}
245247
sector->end_idx = tsl.addr.index;
246248
sector->empty_idx += LOG_IDX_DATA_SIZE;
247249
sector->empty_data -= FDB_WG_ALIGN(tsl.log_len);

0 commit comments

Comments
 (0)