@@ -242,8 +242,8 @@ void Store::addMultipleToStore(
242242 storePathsToAdd.insert (thingToAdd.first .path );
243243 }
244244
245- auto showProgress = [&]() {
246- act.progress (nrDone, pathsToCopy. size () , nrRunning, nrFailed);
245+ auto showProgress = [&, nrTotal = pathsToCopy. size () ]() {
246+ act.progress (nrDone, nrTotal , nrRunning, nrFailed);
247247 };
248248
249249 processGraph<StorePath>(
@@ -1104,9 +1104,6 @@ std::map<StorePath, StorePath> copyPaths(
11041104 return storePathForDst;
11051105 };
11061106
1107- // total is accessed by each copy, which are each handled in separate threads
1108- std::atomic<uint64_t > total = 0 ;
1109-
11101107 for (auto & missingPath : sortedMissing) {
11111108 auto info = srcStore.queryPathInfo (missingPath);
11121109
@@ -1116,9 +1113,10 @@ std::map<StorePath, StorePath> copyPaths(
11161113 ValidPathInfo infoForDst = *info;
11171114 infoForDst.path = storePathForDst;
11181115
1119- auto source = sinkToSource ([&](Sink & sink) {
1116+ auto source = sinkToSource ([&, narSize = info-> narSize ](Sink & sink) {
11201117 // We can reasonably assume that the copy will happen whenever we
11211118 // read the path, so log something about that at that point
1119+ uint64_t total = 0 ;
11221120 auto srcUri = srcStore.getUri ();
11231121 auto dstUri = dstStore.getUri ();
11241122 auto storePathS = srcStore.printStorePath (missingPath);
@@ -1129,13 +1127,13 @@ std::map<StorePath, StorePath> copyPaths(
11291127
11301128 LambdaSink progressSink ([&](std::string_view data) {
11311129 total += data.size ();
1132- act.progress (total, info-> narSize );
1130+ act.progress (total, narSize);
11331131 });
11341132 TeeSink tee { sink, progressSink };
11351133
11361134 srcStore.narFromPath (missingPath, tee);
11371135 });
1138- pathsToCopy.push_back (std::pair{ infoForDst, std::move (source)} );
1136+ pathsToCopy.emplace_back (std::move ( infoForDst) , std::move (source));
11391137 }
11401138
11411139 dstStore.addMultipleToStore (std::move (pathsToCopy), act, repair, checkSigs);
0 commit comments