From 9229e87347271f41f84f87e80d47d9161231cdc1 Mon Sep 17 00:00:00 2001 From: Puck Meerburg Date: Sat, 27 Apr 2024 17:15:51 +0000 Subject: [PATCH] Fix progress bar on copyPaths This variable should not be shared between activities. Change-Id: I4eee89bc7acb320a3972dc3a55bfb087d3a9eb3a --- src/libstore/store-api.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 69e89263b..8c9940c86 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -1085,8 +1085,6 @@ void copyStorePath( auto info = srcStore.queryPathInfo(storePath); - uint64_t total = 0; - // recompute store path on the chance dstStore does it differently if (info->ca && info->references.empty()) { auto info2 = make_ref(*info); @@ -1105,7 +1103,7 @@ void copyStorePath( } auto source = sinkToSource([&](Sink & sink) { - LambdaSink progressSink([&](std::string_view data) { + LambdaSink progressSink([&, total = 0ULL](std::string_view data) mutable { total += data.size(); act.progress(total, info->narSize); }); @@ -1218,9 +1216,6 @@ std::map copyPaths( return storePathForDst; }; - // total is accessed by each copy, which are each handled in separate threads - std::atomic total = 0; - for (auto & missingPath : sortedMissing) { auto info = srcStore.queryPathInfo(missingPath); @@ -1241,7 +1236,7 @@ std::map copyPaths( {storePathS, srcUri, dstUri}); PushActivity pact(act.id); - LambdaSink progressSink([&](std::string_view data) { + LambdaSink progressSink([&, total = 0ULL](std::string_view data) mutable { total += data.size(); act.progress(total, info->narSize); });