Skip to content

Commit e6c8c27

Browse files
committed
fix AI comments
1 parent 4ad5d1d commit e6c8c27

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/db/car/forest.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,12 @@ impl<ReaderT: super::RandomAccessFileReader> ForestCar<ReaderT> {
148148
"not recognizable as a `{FOREST_CAR_FILE_EXTENSION}` file"
149149
))
150150
})?;
151-
let index_start_pos = footer.index - ZSTD_SKIP_FRAME_LEN;
151+
let index_start_pos = footer.index.checked_sub(ZSTD_SKIP_FRAME_LEN).ok_or_else(||
152+
invalid_data(format!(
153+
"unexpected error: footer.index({}) < ZSTD_SKIP_FRAME_LEN({ZSTD_SKIP_FRAME_LEN})",
154+
footer.index
155+
)),
156+
)?;
152157

153158
let cursor = Cursor::new_pos(&reader, 0);
154159
let mut header_zstd_frame = decode_zstd_single_frame(cursor)?.into();

src/db/car/forest/index/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ impl Writer {
476476
}
477477
pub async fn write_zstd_skip_frames_into(self, writer: impl AsyncWrite) -> io::Result<()> {
478478
// write every 128MiB slots to a skip frame
479-
const CHUNK_FRAME_DATA_MAX_BYTES: usize = 128 * 1024;
479+
const CHUNK_FRAME_DATA_MAX_BYTES: usize = 128 * 1024 * 1024;
480480
let written_len = self.written_len();
481481
self.write_zstd_skip_frames_into_inner(
482482
writer,

0 commit comments

Comments
 (0)