lore-storage: Make read_into respect the byte range for single-fragment reads#37
lore-storage: Make read_into respect the byte range for single-fragment reads#37itsfuad wants to merge 1 commit into
Conversation
rajpratham1
left a comment
There was a problem hiding this comment.
This is a focused bug fix that addresses a clear inconsistency in read_into. The change is minimal, aligns the single-fragment paths with the existing fragmented implementation and read(), and includes a regression test that reproduces the original issue. I don't see any blocking concerns.
|
Looks good - make sure you follow the guidelines at https://github.com/EpicGames/lore/blob/main/CONTRIBUTING.md#dco-sign-off and do the DCO signoff on the commits to let us take this in. |
@mjansson Done. Review please. |
Fixes EpicGames#25. The two single-fragment branches (compressed and uncompressed) in read_into now apply buffer.slice(range) before copying into the output slice, matching what read() already does. Added a regression test that stores a 100-byte fragment and reads bytes 10..50 into a 40-byte buffer. Signed-off-by: Fuad Hasan <fuad.cs22@gmail.com>
|
@mjansson Fixed clippy issues in workflow run. |
What:
Make
read_intorespect the byte range for single-fragment reads inlore-storage.Why:
read_intoaccepts an optional byterange, but both single-fragment branches (compressed and uncompressed) were comparingslice.len()against the full fragment payload instead of the requested range. Any partial read on a file ≤ 256 KiB (theFRAGMENT_SIZE_THRESHOLD) would fail withunexpected size: slice 40 vs buffer 100. The fragmented branch and the siblingread()both handle this correctly, onlyread_into's single-fragment paths were missing it.Fixes #25
How:
Added one line to each single-fragment branch to slice the buffer to the requested range before the existing size check and copy:
Testing:
Added a regression test that stores a 100-byte fragment and reads bytes 10..50 into a 40-byte buffer, reproducing the original failure.