Skip to content

Commit a305883

Browse files
authored
Merge pull request #12547 from NixOS/mergify/bp/2.26-maintenance/pr-12510
libstore: fix expected bytes in progress bar (backport #12510)
2 parents 0d039d4 + c69d5af commit a305883

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/libstore/store-api.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,22 @@ void Store::addMultipleToStore(
230230
{
231231
std::atomic<size_t> nrDone{0};
232232
std::atomic<size_t> nrFailed{0};
233-
std::atomic<uint64_t> bytesExpected{0};
234233
std::atomic<uint64_t> nrRunning{0};
235234

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

237+
uint64_t bytesExpected = 0;
238+
238239
std::map<StorePath, PathWithInfo *> infosMap;
239240
StorePathSet storePathsToAdd;
240241
for (auto & thingToAdd : pathsToCopy) {
242+
bytesExpected += thingToAdd.first.narSize;
241243
infosMap.insert_or_assign(thingToAdd.first.path, &thingToAdd);
242244
storePathsToAdd.insert(thingToAdd.first.path);
243245
}
244246

247+
act.setExpected(actCopyPath, bytesExpected);
248+
245249
auto showProgress = [&, nrTotal = pathsToCopy.size()]() {
246250
act.progress(nrDone, nrTotal, nrRunning, nrFailed);
247251
};
@@ -259,9 +263,6 @@ void Store::addMultipleToStore(
259263
return StorePathSet();
260264
}
261265

262-
bytesExpected += info.narSize;
263-
act.setExpected(actCopyPath, bytesExpected);
264-
265266
return info.references;
266267
},
267268

0 commit comments

Comments
 (0)