Summary
read_into in lore-storage/src/read.rs takes an optional byte range, but for a single, non-fragmented fragment it ignores the range and copies the whole fragment. The caller's slice is sized to range.len(), so any partial read returns Err("unexpected size: slice N vs buffer M") (read.rs:560).
Files up to FRAGMENT_SIZE_THRESHOLD (256 KiB) are stored as one fragment, and the swfs/projfs read handlers call read_into with Some(offset..offset + len). So reading a small file at any non-zero offset fails. The read() function in the same file applies the range correctly with buffer.slice(range) (read.rs:459), as does the fragmented branch; only the single-fragment branches of read_into drop it.
Steps to reproduce
// 100-byte fragment, read bytes 10..50
let mut out = [0u8; 40];
read_into(store, partition, addr, Some(10..50), &mut out, opts, None).await;
// expected: Ok(()), out == content[10..50]
// actual: Err("unexpected size: slice 40 vs buffer 100")
I have a fix (apply range in both single-fragment branches, the way read() already does) plus a regression test. Happy to open a PR.
Summary
read_intoinlore-storage/src/read.rstakes an optional byterange, but for a single, non-fragmented fragment it ignores the range and copies the whole fragment. The caller's slice is sized torange.len(), so any partial read returnsErr("unexpected size: slice N vs buffer M")(read.rs:560).Files up to
FRAGMENT_SIZE_THRESHOLD(256 KiB) are stored as one fragment, and the swfs/projfs read handlers callread_intowithSome(offset..offset + len). So reading a small file at any non-zero offset fails. Theread()function in the same file applies the range correctly withbuffer.slice(range)(read.rs:459), as does the fragmented branch; only the single-fragment branches ofread_intodrop it.Steps to reproduce
I have a fix (apply
rangein both single-fragment branches, the wayread()already does) plus a regression test. Happy to open a PR.