Skip to content

Commit d511286

Browse files
committed
fix off by one bug in the quick hacky valid_ranges
1 parent a8015d5 commit d511286

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/downloader2.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ mod tests {
510510
#![allow(clippy::single_range_in_vec_init)]
511511
use std::ops::Range;
512512

513-
use crate::net_protocol::Blobs;
513+
use crate::{net_protocol::Blobs, store::MapMut};
514514

515515
use super::*;
516516
use bao_tree::ChunkNum;
@@ -546,6 +546,16 @@ mod tests {
546546
SecretKey::from(secret).public()
547547
}
548548

549+
#[tokio::test]
550+
async fn test_chunk_ranges() -> TestResult<()> {
551+
let store = crate::store::mem::Store::new();
552+
let tt = store.import_bytes(vec![0u8;1025].into(), crate::BlobFormat::Raw).await?;
553+
let entry = store.get_mut(tt.hash()).await?.unwrap();
554+
let valid = crate::get::db::valid_ranges::<crate::store::mem::Store>(&entry).await?;
555+
println!("{valid:?}");
556+
Ok(())
557+
}
558+
549559
#[test]
550560
fn test_planner_1() {
551561
let mut planner = StripePlanner2::new(0, 4);

src/get/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ pub async fn valid_ranges<D: MapMut>(entry: &D::EntryMut) -> anyhow::Result<Chun
241241
// compute the valid range from just looking at the data file
242242
let mut data_reader = entry.data_reader().await?;
243243
let data_size = data_reader.size().await?;
244-
let valid_from_data = ChunkRanges::from(..ChunkNum::full_chunks(data_size));
244+
let valid_from_data = ChunkRanges::from(..ChunkNum::chunks(data_size));
245245
// compute the valid range from just looking at the outboard file
246246
let mut outboard = entry.outboard().await?;
247247
let all = ChunkRanges::all();

0 commit comments

Comments
 (0)