aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2026-03-15 20:01:30 +0100
committerDan Engelbrecht <[email protected]>2026-03-15 20:15:59 +0100
commit6e28fbdb43b3cebbe536d9b0adae218316b05171 (patch)
treeccd7f574f7ce62272e4d5cb50a3a5a540286466e
parentcleanup and typos (diff)
downloadzen-6e28fbdb43b3cebbe536d9b0adae218316b05171.tar.xz
zen-6e28fbdb43b3cebbe536d9b0adae218316b05171.zip
more fixes
-rw-r--r--src/zenremotestore/projectstore/remoteprojectstore.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/zenremotestore/projectstore/remoteprojectstore.cpp b/src/zenremotestore/projectstore/remoteprojectstore.cpp
index f0e55b2b1..0d1827aee 100644
--- a/src/zenremotestore/projectstore/remoteprojectstore.cpp
+++ b/src/zenremotestore/projectstore/remoteprojectstore.cpp
@@ -984,6 +984,13 @@ namespace remotestore_impl {
AttachmentPath,
OodleCompressor::Mermaid,
OodleCompressionLevel::VeryFast);
+ if (!TempAttachmentBuffer)
+ {
+ throw std::runtime_error(fmt::format("Failed to compressed source file for blob {} from '{}' to '{}'",
+ RawHash,
+ RawPath,
+ AttachmentPath));
+ }
TempAttachmentBuffer.SetDeleteOnClose(true);
ZEN_INFO("Saved temp attachment to '{}', {} ({})",
@@ -2639,7 +2646,6 @@ BuildContainer(CidStore& ChunkStore,
std::unordered_set<IoHash, IoHash::Hasher> MissingHashes;
std::vector<remotestore_impl::FoundChunkedFile> AttachmentsToChunk;
- Stopwatch CompressOpsTimer;
remotestore_impl::FindChunkSizes(ChunkStore,
WorkerPool,
MaxChunkEmbedSize,
@@ -3297,7 +3303,8 @@ SaveOplog(CidStore& ChunkStore,
auto UploadBlock = [&RemoteStore, &RemoteStoreInfo, &Info, OptionalContext](CompressedBuffer&& CompressedBlock,
ChunkBlockDescription&& Block) {
- IoHash BlockHash = Block.BlockHash;
+ IoHash BlockHash = Block.BlockHash;
+ uint64_t CompressedSize = CompressedBlock.GetCompressedSize();
RemoteProjectStore::SaveAttachmentResult Result =
RemoteStore.SaveAttachment(CompressedBlock.GetCompressed(), BlockHash, std::move(Block));
if (Result.ErrorCode)
@@ -3310,13 +3317,13 @@ SaveOplog(CidStore& ChunkStore,
Result.Text);
}
Info.AttachmentBlocksUploaded.fetch_add(1);
- Info.AttachmentBlockBytesUploaded.fetch_add(CompressedBlock.GetCompressedSize());
- ZEN_DEBUG("Saved block {}, {}", BlockHash, NiceBytes(CompressedBlock.GetCompressedSize()));
+ Info.AttachmentBlockBytesUploaded.fetch_add(CompressedSize);
+ ZEN_DEBUG("Saved block {}, {}", BlockHash, NiceBytes(CompressedSize));
};
std::vector<std::vector<std::pair<IoHash, FetchChunkFunc>>> BlockChunks;
auto OnBlockChunks = [&BlockChunks](std::vector<std::pair<IoHash, FetchChunkFunc>>&& Chunks) {
- BlockChunks.push_back({Chunks.begin(), Chunks.end()});
+ BlockChunks.push_back({std::make_move_iterator(Chunks.begin()), std::make_move_iterator(Chunks.end())});
ZEN_DEBUG("Found {} block chunks", Chunks.size());
};
@@ -4292,15 +4299,16 @@ LoadOplog(LoadOplogContext&& Context)
Latch DechunkLatch(1);
std::filesystem::path TempFilePath = Context.Oplog.TempPath();
- for (const ChunkedInfo& Chunked : FilesToDechunk)
+ for (size_t ChunkedIndex = 0; ChunkedIndex < FilesToDechunk.size(); ChunkedIndex++)
{
+ const ChunkedInfo& Chunked = FilesToDechunk[ChunkedIndex];
std::filesystem::path TempFileName = TempFilePath / Chunked.RawHash.ToHexString();
DechunkLatch.AddCount(1);
Context.WorkerPool.ScheduleWork(
- [&Context, &DechunkLatch, TempFileName, &Chunked, &RemoteResult, &Info]() {
+ [&Context, &DechunkLatch, TempFileName, &FilesToDechunk, ChunkedIndex, &RemoteResult, &Info]() {
ZEN_TRACE_CPU("DechunkAttachment");
- auto _ = MakeGuard([&DechunkLatch, &TempFileName] {
+ auto _ = MakeGuard([&DechunkLatch, &TempFileName] {
std::error_code Ec;
if (IsFile(TempFileName, Ec))
{
@@ -4312,6 +4320,8 @@ LoadOplog(LoadOplogContext&& Context)
}
DechunkLatch.CountDown();
});
+ const ChunkedInfo& Chunked = FilesToDechunk[ChunkedIndex];
+
try
{
if (RemoteResult.IsError())
@@ -4319,7 +4329,8 @@ LoadOplog(LoadOplogContext&& Context)
return;
}
Stopwatch Timer;
- IoBuffer TmpBuffer;
+
+ IoBuffer TmpBuffer;
{
BasicFile TmpFile;
std::error_code Ec;
@@ -4327,7 +4338,7 @@ LoadOplog(LoadOplogContext&& Context)
if (Ec)
{
RemoteResult.SetError(gsl::narrow<int>(HttpResponseCode::InternalServerError),
- "Missing chunk",
+ "Write error",
fmt::format("Failed to open temp file {} for chunked attachment {}",
TempFileName,
Chunked.RawHash));