diff options
| author | Dan Engelbrecht <[email protected]> | 2025-03-07 09:58:20 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-03-07 09:58:20 +0100 |
| commit | 9b24647facccc9c7848a52f1f4c5e32055bf2f01 (patch) | |
| tree | d798889a2b3f6a0d72331890b75e92b0159ce0c3 /src/zenutil/filebuildstorage.cpp | |
| parent | reduced memory churn using fixed_xxx containers (#236) (diff) | |
| download | zen-9b24647facccc9c7848a52f1f4c5e32055bf2f01.tar.xz zen-9b24647facccc9c7848a52f1f4c5e32055bf2f01.zip | |
partial block fetch (#298)
- Improvement: Do partial requests of blocks if not all of the block is needed
- Improvement: Better progress/statistics on download
- Bugfix: Ensure that temporary folder for Jupiter downloads exists during verify phase
Diffstat (limited to 'src/zenutil/filebuildstorage.cpp')
| -rw-r--r-- | src/zenutil/filebuildstorage.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/zenutil/filebuildstorage.cpp b/src/zenutil/filebuildstorage.cpp index a4bb759e7..e57109006 100644 --- a/src/zenutil/filebuildstorage.cpp +++ b/src/zenutil/filebuildstorage.cpp @@ -325,7 +325,7 @@ public: return {}; } - virtual IoBuffer GetBuildBlob(const Oid& BuildId, const IoHash& RawHash) override + virtual IoBuffer GetBuildBlob(const Oid& BuildId, const IoHash& RawHash, uint64_t RangeOffset, uint64_t RangeBytes) override { ZEN_UNUSED(BuildId); SimulateLatency(0, 0); @@ -337,10 +337,19 @@ public: if (std::filesystem::is_regular_file(BlockPath)) { BasicFile File(BlockPath, BasicFile::Mode::kRead); - IoBuffer Payload = File.ReadAll(); - ZEN_ASSERT_SLOW(ValidateCompressedBuffer(RawHash, CompositeBuffer(SharedBuffer(Payload)))); - m_Stats.TotalBytesRead += Payload.GetSize(); + IoBuffer Payload; + if (RangeOffset != 0 || RangeBytes != (uint64_t)-1) + { + Payload = IoBuffer(RangeBytes); + File.Read(Payload.GetMutableView().GetData(), RangeBytes, RangeOffset); + } + else + { + Payload = File.ReadAll(); + ZEN_ASSERT_SLOW(ValidateCompressedBuffer(RawHash, CompositeBuffer(SharedBuffer(Payload)))); + } Payload.SetContentType(ZenContentType::kCompressedBinary); + m_Stats.TotalBytesRead += Payload.GetSize(); SimulateLatency(0, Payload.GetSize()); return Payload; } |