Skip to content

Commit

Permalink
Fix progress bar on copyPaths
Browse files Browse the repository at this point in the history
This variable should not be shared between activities.

Change-Id: I4eee89bc7acb320a3972dc3a55bfb087d3a9eb3a
  • Loading branch information
puckipedia committed Apr 27, 2024
1 parent 4b6ba05 commit fa3ff5c
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/libstore/store-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<ValidPathInfo>(*info);
Expand All @@ -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);
});
Expand Down Expand Up @@ -1218,9 +1216,6 @@ std::map<StorePath, StorePath> copyPaths(
return storePathForDst;
};

// total is accessed by each copy, which are each handled in separate threads
std::atomic<uint64_t> total = 0;

for (auto & missingPath : sortedMissing) {
auto info = srcStore.queryPathInfo(missingPath);

Expand All @@ -1241,7 +1236,7 @@ std::map<StorePath, StorePath> 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);
});
Expand Down

0 comments on commit fa3ff5c

Please sign in to comment.