aboutsummaryrefslogtreecommitdiff
path: root/zenserver/compute/apply.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zenserver/compute/apply.cpp')
-rw-r--r--zenserver/compute/apply.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/zenserver/compute/apply.cpp b/zenserver/compute/apply.cpp
index 7b76bb80b..2c3243655 100644
--- a/zenserver/compute/apply.cpp
+++ b/zenserver/compute/apply.cpp
@@ -659,16 +659,21 @@ HttpFunctionService::ExecAction(const WorkerDesc& Worker, CbObject Action)
{
CbObjectView ExecEntry = It.AsObjectView();
- std::string_view Name = ExecEntry["name"sv].AsString();
- const IoHash Hash = ExecEntry["hash"sv].AsHash();
- const uint64_t Size = ExecEntry["size"sv].AsUInt64();
+ std::string_view Name = ExecEntry["name"sv].AsString();
+ const IoHash ChunkHash = ExecEntry["hash"sv].AsHash();
+ const uint64_t Size = ExecEntry["size"sv].AsUInt64();
std::filesystem::path FilePath{SandboxPath / Name};
- IoBuffer DataBuffer = m_CasStore.FindChunk(Hash);
+ IoBuffer DataBuffer = m_CasStore.FindChunk(ChunkHash);
if (!DataBuffer)
{
- throw std::runtime_error("worker CAS chunk '{}' missing"_format(Hash));
+ throw std::runtime_error("worker CAS chunk '{}' missing"_format(ChunkHash));
+ }
+
+ if (DataBuffer.Size() != Size)
+ {
+ throw std::runtime_error("worker CAS chunk '{}' size: {}, action spec expected {}"_format(ChunkHash, DataBuffer.Size(), Size));
}
zen::WriteFile(FilePath, DataBuffer);
@@ -685,16 +690,21 @@ HttpFunctionService::ExecAction(const WorkerDesc& Worker, CbObject Action)
{
CbObjectView FileEntry = It.AsObjectView();
- std::string_view Name = FileEntry["name"sv].AsString();
- const IoHash Hash = FileEntry["hash"sv].AsHash();
- const uint64_t Size = FileEntry["size"sv].AsUInt64();
+ std::string_view Name = FileEntry["name"sv].AsString();
+ const IoHash ChunkHash = FileEntry["hash"sv].AsHash();
+ const uint64_t Size = FileEntry["size"sv].AsUInt64();
std::filesystem::path FilePath{SandboxPath / Name};
- IoBuffer DataBuffer = m_CasStore.FindChunk(Hash);
+ IoBuffer DataBuffer = m_CasStore.FindChunk(ChunkHash);
if (!DataBuffer)
{
- throw std::runtime_error("worker CAS chunk '{}' missing"_format(Hash));
+ throw std::runtime_error("worker CAS chunk '{}' missing"_format(ChunkHash));
+ }
+
+ if (DataBuffer.Size() != Size)
+ {
+ throw std::runtime_error("worker CAS chunk '{}' size: {}, action spec expected {}"_format(ChunkHash, DataBuffer.Size(), Size));
}
zen::WriteFile(FilePath, DataBuffer);