aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/chunkedcontent.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-02-28 12:39:48 +0100
committerGitHub Enterprise <[email protected]>2025-02-28 12:39:48 +0100
commit5791f51cccea1d4e5365456c8da89dbac0dd3ec0 (patch)
tree137412a5e731a4ac33b53b0f0d33b39b29975a03 /src/zenutil/chunkedcontent.cpp
parent5.5.20 (diff)
downloadzen-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/chunkedcontent.cpp')
-rw-r--r--src/zenutil/chunkedcontent.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/zenutil/chunkedcontent.cpp b/src/zenutil/chunkedcontent.cpp
index a41b71972..6dc2a20d8 100644
--- a/src/zenutil/chunkedcontent.cpp
+++ b/src/zenutil/chunkedcontent.cpp
@@ -92,7 +92,8 @@ namespace {
tsl::robin_map<IoHash, uint32_t, IoHash::Hasher>& RawHashToSequenceRawHashIndex,
RwLock& Lock,
const std::filesystem::path& FolderPath,
- uint32_t PathIndex)
+ uint32_t PathIndex,
+ std::atomic<bool>& AbortFlag)
{
const uint64_t RawSize = OutChunkedContent.RawSizes[PathIndex];
const std::filesystem::path& Path = OutChunkedContent.Paths[PathIndex];
@@ -105,7 +106,7 @@ namespace {
{
ChunkedInfoWithSource Chunked;
const bool DidChunking =
- InChunkingController.ProcessFile((FolderPath / Path).make_preferred(), RawSize, Chunked, Stats.BytesHashed);
+ InChunkingController.ProcessFile((FolderPath / Path).make_preferred(), RawSize, Chunked, Stats.BytesHashed, AbortFlag);
if (DidChunking)
{
Lock.WithExclusiveLock([&]() {
@@ -753,15 +754,13 @@ ChunkFolderContent(ChunkingStatistics& Stats,
RawHashToSequenceRawHashIndex,
Lock,
RootPath,
- PathIndex);
+ PathIndex,
+ AbortFlag);
Lock.WithExclusiveLock([&]() { Result.RawHashes[PathIndex] = RawHash; });
Stats.FilesProcessed++;
}
},
- [&, PathIndex](const std::exception& Ex, std::atomic<bool>& AbortFlag) {
- ZEN_CONSOLE("Failed scanning file {}. Reason: {}", Result.Paths[PathIndex], Ex.what());
- AbortFlag = true;
- });
+ Work.DefaultErrorFunction());
}
Work.Wait(UpdateInteralMS, [&](bool IsAborted, std::ptrdiff_t PendingWork) {