Skip to content

Commit

Permalink
Merge pull request #12510 from tie/fix-progress-parallel
Browse files Browse the repository at this point in the history
libstore: fix expected bytes in progress bar
  • Loading branch information
edolstra authored Feb 21, 2025
2 parents 223f82e + eb73bfc commit d904921
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/libstore/store-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,22 @@ void Store::addMultipleToStore(
{
std::atomic<size_t> nrDone{0};
std::atomic<size_t> nrFailed{0};
std::atomic<uint64_t> bytesExpected{0};
std::atomic<uint64_t> nrRunning{0};

using PathWithInfo = std::pair<ValidPathInfo, std::unique_ptr<Source>>;

uint64_t bytesExpected = 0;

std::map<StorePath, PathWithInfo *> infosMap;
StorePathSet storePathsToAdd;
for (auto & thingToAdd : pathsToCopy) {
bytesExpected += thingToAdd.first.narSize;
infosMap.insert_or_assign(thingToAdd.first.path, &thingToAdd);
storePathsToAdd.insert(thingToAdd.first.path);
}

act.setExpected(actCopyPath, bytesExpected);

auto showProgress = [&, nrTotal = pathsToCopy.size()]() {
act.progress(nrDone, nrTotal, nrRunning, nrFailed);
};
Expand All @@ -259,9 +263,6 @@ void Store::addMultipleToStore(
return StorePathSet();
}

bytesExpected += info.narSize;
act.setExpected(actCopyPath, bytesExpected);

return info.references;
},

Expand Down

0 comments on commit d904921

Please sign in to comment.