aboutsummaryrefslogtreecommitdiff
path: root/src/zenremotestore/projectstore/zenremoteprojectstore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenremotestore/projectstore/zenremoteprojectstore.cpp')
-rw-r--r--src/zenremotestore/projectstore/zenremoteprojectstore.cpp50
1 files changed, 41 insertions, 9 deletions
diff --git a/src/zenremotestore/projectstore/zenremoteprojectstore.cpp b/src/zenremotestore/projectstore/zenremoteprojectstore.cpp
index ab82edbef..115d6438d 100644
--- a/src/zenremotestore/projectstore/zenremoteprojectstore.cpp
+++ b/src/zenremotestore/projectstore/zenremoteprojectstore.cpp
@@ -159,7 +159,8 @@ public:
virtual LoadAttachmentsResult LoadAttachments(const std::vector<IoHash>& RawHashes) override
{
- std::string LoadRequest = fmt::format("/{}/oplog/{}/rpc"sv, m_Project, m_Oplog);
+ LoadAttachmentsResult Result;
+ std::string LoadRequest = fmt::format("/{}/oplog/{}/rpc"sv, m_Project, m_Oplog);
CbObject Request;
{
@@ -187,7 +188,7 @@ public:
HttpClient::Response Response = m_Client.Post(LoadRequest, Request, HttpClient::Accept(ZenContentType::kCbPackage));
AddStats(Response);
- LoadAttachmentsResult Result = LoadAttachmentsResult{ConvertResult(Response)};
+ Result = LoadAttachmentsResult{ConvertResult(Response)};
if (Result.ErrorCode)
{
Result.Reason = fmt::format("Failed fetching {} oplog attachments from {}/{}/{}. Reason: '{}'",
@@ -249,20 +250,49 @@ public:
return GetKnownBlocksResult{{.ErrorCode = static_cast<int>(HttpResponseCode::NoContent)}};
}
+ virtual GetBlockDescriptionsResult GetBlockDescriptions(std::span<const IoHash> BlockHashes,
+ BuildStorageCache* OptionalCache,
+ const Oid& CacheBuildId) override
+ {
+ ZEN_UNUSED(BlockHashes, OptionalCache, CacheBuildId);
+ return GetBlockDescriptionsResult{Result{.ErrorCode = int(HttpResponseCode::NotFound)}};
+ }
+
virtual LoadAttachmentResult LoadAttachment(const IoHash& RawHash) override
{
+ LoadAttachmentResult Result;
std::string LoadRequest = fmt::format("/{}/oplog/{}/{}"sv, m_Project, m_Oplog, RawHash);
HttpClient::Response Response =
m_Client.Download(LoadRequest, m_TempFilePath, HttpClient::Accept(ZenContentType::kCompressedBinary));
AddStats(Response);
- LoadAttachmentResult Result = LoadAttachmentResult{ConvertResult(Response)};
- if (!Result.ErrorCode)
+ Result = LoadAttachmentResult{ConvertResult(Response)};
+ if (Result.ErrorCode)
{
- Result.Bytes = Response.ResponsePayload;
- Result.Bytes.MakeOwned();
+ Result.Reason = fmt::format("Failed fetching oplog attachment from {}/{}/{}/{}. Reason: '{}'",
+ m_ProjectStoreUrl,
+ m_Project,
+ m_Oplog,
+ RawHash,
+ Result.Reason);
}
- if (!Result.ErrorCode)
+ Result.Bytes = Response.ResponsePayload;
+ Result.Bytes.MakeOwned();
+ return Result;
+ }
+
+ virtual LoadAttachmentRangesResult LoadAttachmentRanges(const IoHash& RawHash,
+ std::span<const std::pair<uint64_t, uint64_t>> Ranges) override
+ {
+ ZEN_ASSERT(!Ranges.empty());
+ LoadAttachmentRangesResult Result;
+ std::string LoadRequest = fmt::format("/{}/oplog/{}/{}"sv, m_Project, m_Oplog, RawHash);
+ HttpClient::Response Response =
+ m_Client.Download(LoadRequest, m_TempFilePath, HttpClient::Accept(ZenContentType::kCompressedBinary));
+ AddStats(Response);
+
+ Result = LoadAttachmentRangesResult{ConvertResult(Response)};
+ if (Result.ErrorCode)
{
Result.Reason = fmt::format("Failed fetching oplog attachment from {}/{}/{}/{}. Reason: '{}'",
m_ProjectStoreUrl,
@@ -271,11 +301,13 @@ public:
RawHash,
Result.Reason);
}
+ else
+ {
+ Result.Ranges = std::vector<std::pair<uint64_t, uint64_t>>(Ranges.begin(), Ranges.end());
+ }
return Result;
}
- virtual void Flush() override {}
-
private:
void AddStats(const HttpClient::Response& Result)
{