aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/chunkingcontroller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenutil/chunkingcontroller.cpp')
-rw-r--r--src/zenutil/chunkingcontroller.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/zenutil/chunkingcontroller.cpp b/src/zenutil/chunkingcontroller.cpp
index bc0e57b14..017d12433 100644
--- a/src/zenutil/chunkingcontroller.cpp
+++ b/src/zenutil/chunkingcontroller.cpp
@@ -58,7 +58,8 @@ public:
virtual bool ProcessFile(const std::filesystem::path& InputPath,
uint64_t RawSize,
ChunkedInfoWithSource& OutChunked,
- std::atomic<uint64_t>& BytesProcessed) const override
+ std::atomic<uint64_t>& BytesProcessed,
+ std::atomic<bool>& AbortFlag) const override
{
const bool ExcludeFromChunking =
std::find(m_ChunkExcludeExtensions.begin(), m_ChunkExcludeExtensions.end(), InputPath.extension()) !=
@@ -70,7 +71,7 @@ public:
}
BasicFile Buffer(InputPath, BasicFile::Mode::kRead);
- OutChunked = ChunkData(Buffer, 0, RawSize, m_ChunkingParams, &BytesProcessed);
+ OutChunked = ChunkData(Buffer, 0, RawSize, m_ChunkingParams, &BytesProcessed, &AbortFlag);
return true;
}
@@ -132,7 +133,8 @@ public:
virtual bool ProcessFile(const std::filesystem::path& InputPath,
uint64_t RawSize,
ChunkedInfoWithSource& OutChunked,
- std::atomic<uint64_t>& BytesProcessed) const override
+ std::atomic<uint64_t>& BytesProcessed,
+ std::atomic<bool>& AbortFlag) const override
{
if (RawSize < m_ChunkFileSizeLimit)
{
@@ -150,6 +152,10 @@ public:
ChunkHashToChunkIndex.reserve(1 + (RawSize / m_FixedChunkingChunkSize));
while (Offset < RawSize)
{
+ if (AbortFlag)
+ {
+ return false;
+ }
uint64_t ChunkSize = std::min<uint64_t>(RawSize - Offset, m_FixedChunkingChunkSize);
IoBuffer Chunk(Source, Offset, ChunkSize);
MemoryView ChunkData = Chunk.GetView();