diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/zen/cmds/builds_cmd.cpp | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/src/zen/cmds/builds_cmd.cpp b/src/zen/cmds/builds_cmd.cpp index a9852151f..132f5db86 100644 --- a/src/zen/cmds/builds_cmd.cpp +++ b/src/zen/cmds/builds_cmd.cpp @@ -3288,8 +3288,8 @@ namespace { const CompositeBuffer& DecompressedBlockBuffer, const ChunkedContentLookup& Lookup, std::atomic<bool>* RemoteChunkIndexNeedsCopyFromSourceFlags, - uint32_t& OutChunksComplete, - uint64_t& OutBytesWritten) + std::atomic<uint32_t>& OutChunksComplete, + std::atomic<uint64_t>& OutBytesWritten) { std::vector<CompositeBuffer> ChunkBuffers; struct WriteOpData @@ -3447,7 +3447,7 @@ namespace { std::span<const ChunkedContentLookup::ChunkSequenceLocation* const> ChunkTargets, const CompositeBuffer& ChunkData, WriteFileCache& OpenFileCache, - uint64_t& OutBytesWritten) + std::atomic<uint64_t>& OutBytesWritten) { for (const ChunkedContentLookup::ChunkSequenceLocation* TargetPtr : ChunkTargets) { @@ -3639,16 +3639,14 @@ namespace { { WriteFileCache OpenFileCache; - uint64_t TotalBytesWritten = 0; WriteChunkToDisk(CacheFolderPath, RemoteContent, RemoteLookup, ChunkTargetPtrs, CompositeBuffer(Chunk), OpenFileCache, - TotalBytesWritten); + WriteToDiskBytes); ChunksComplete++; - WriteToDiskBytes += TotalBytesWritten; } } @@ -3964,7 +3962,6 @@ namespace { } else { - uint64_t TotalBytesWritten = 0; SharedBuffer Chunk = Decompress(CompressedPart, ChunkHash, @@ -3978,9 +3975,8 @@ namespace { ChunkTargetPtrs, CompositeBuffer(Chunk), OpenFileCache, - TotalBytesWritten); + WriteToDiskBytes); ChunkCountWritten++; - WriteToDiskBytes += TotalBytesWritten; } } if (!AbortFlag) @@ -4240,21 +4236,14 @@ namespace { ZEN_ASSERT_SLOW(BlockDescriptions[BlockIndex].BlockHash == IoHash::HashBuffer(DecompressedBlockBuffer)); - uint64_t BytesWrittenToDisk = 0; - uint32_t ChunksReadFromBlock = 0; - if (WriteBlockToDisk(CacheFolderPath, - RemoteContent, - SequenceIndexChunksLeftToWriteCounters, - DecompressedBlockBuffer, - RemoteLookup, - RemoteChunkIndexNeedsCopyFromSourceFlags.data(), - ChunksReadFromBlock, - BytesWrittenToDisk)) - { - WriteToDiskBytes += BytesWrittenToDisk; - ChunkCountWritten += ChunksReadFromBlock; - } - else + if (!WriteBlockToDisk(CacheFolderPath, + RemoteContent, + SequenceIndexChunksLeftToWriteCounters, + DecompressedBlockBuffer, + RemoteLookup, + RemoteChunkIndexNeedsCopyFromSourceFlags.data(), + ChunkCountWritten, + WriteToDiskBytes)) { throw std::runtime_error( fmt::format("Block {} is malformed", BlockDescriptions[BlockIndex].BlockHash)); |