diff options
| author | Dan Engelbrecht <[email protected]> | 2025-02-28 12:39:48 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-02-28 12:39:48 +0100 |
| commit | 5791f51cccea1d4e5365456c8da89dbac0dd3ec0 (patch) | |
| tree | 137412a5e731a4ac33b53b0f0d33b39b29975a03 /src/zenutil/chunkingcontroller.cpp | |
| parent | 5.5.20 (diff) | |
| download | zen-5791f51cccea1d4e5365456c8da89dbac0dd3ec0.tar.xz zen-5791f51cccea1d4e5365456c8da89dbac0dd3ec0.zip | |
improve error handling (#289)
* clearer errors
* quicker abort
* handle deleted local files
* simplify parallellwork error handling
* don't finish progress on destructor - gives wrong impression
* graceful ctrl-c handling
Diffstat (limited to 'src/zenutil/chunkingcontroller.cpp')
| -rw-r--r-- | src/zenutil/chunkingcontroller.cpp | 12 |
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(); |