mirror of
https://github.com/NixOS/nix
synced 2025-06-27 16:51:15 +02:00
Progress indicator: Show number of active items
This commit is contained in:
parent
0e0dcf2c7e
commit
bf1f123b09
7 changed files with 39 additions and 28 deletions
|
@ -202,16 +202,6 @@ struct Child
|
|||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct MaintainCount
|
||||
{
|
||||
T & counter;
|
||||
T delta;
|
||||
MaintainCount(T & counter, T delta = 1) : counter(counter), delta(delta) { counter += delta; }
|
||||
~MaintainCount() { counter -= delta; }
|
||||
};
|
||||
|
||||
|
||||
/* The worker class. */
|
||||
class Worker
|
||||
{
|
||||
|
@ -271,6 +261,7 @@ public:
|
|||
|
||||
uint64_t expectedSubstitutions = 0;
|
||||
uint64_t doneSubstitutions = 0;
|
||||
uint64_t runningSubstitutions = 0;
|
||||
uint64_t expectedDownloadSize = 0;
|
||||
uint64_t doneDownloadSize = 0;
|
||||
uint64_t expectedNarSize = 0;
|
||||
|
@ -337,7 +328,7 @@ public:
|
|||
|
||||
void updateProgress()
|
||||
{
|
||||
actSubstitutions.progress(doneSubstitutions, expectedSubstitutions + doneSubstitutions);
|
||||
actSubstitutions.progress(doneSubstitutions, expectedSubstitutions + doneSubstitutions, runningSubstitutions);
|
||||
logger->event(evSetExpected, act, actDownload, expectedDownloadSize + doneDownloadSize);
|
||||
logger->event(evSetExpected, act, actCopyPath, expectedNarSize + doneNarSize);
|
||||
}
|
||||
|
@ -3333,7 +3324,7 @@ private:
|
|||
Path destPath;
|
||||
|
||||
std::unique_ptr<MaintainCount<uint64_t>> maintainExpectedSubstitutions,
|
||||
maintainExpectedNar, maintainExpectedDownload;
|
||||
maintainRunningSubstitutions, maintainExpectedNar, maintainExpectedDownload;
|
||||
|
||||
typedef void (SubstitutionGoal::*GoalState)();
|
||||
GoalState state;
|
||||
|
@ -3531,6 +3522,9 @@ void SubstitutionGoal::tryToRun()
|
|||
|
||||
printInfo(format("fetching path '%1%'...") % storePath);
|
||||
|
||||
maintainRunningSubstitutions = std::make_unique<MaintainCount<uint64_t>>(worker.runningSubstitutions);
|
||||
worker.updateProgress();
|
||||
|
||||
outPipe.create();
|
||||
|
||||
promise = std::promise<void>();
|
||||
|
@ -3578,6 +3572,8 @@ void SubstitutionGoal::finished()
|
|||
printMsg(lvlChatty,
|
||||
format("substitution of path '%1%' succeeded") % storePath);
|
||||
|
||||
maintainRunningSubstitutions.reset();
|
||||
|
||||
maintainExpectedSubstitutions.reset();
|
||||
worker.doneSubstitutions++;
|
||||
|
||||
|
|
|
@ -625,9 +625,10 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const PathSet & storePa
|
|||
|
||||
std::atomic<size_t> nrDone{0};
|
||||
std::atomic<uint64_t> bytesExpected{0};
|
||||
std::atomic<uint64_t> nrRunning{0};
|
||||
|
||||
auto showProgress = [&]() {
|
||||
act.progress(nrDone, missing.size());
|
||||
act.progress(nrDone, missing.size(), nrRunning);
|
||||
};
|
||||
|
||||
ThreadPool pool;
|
||||
|
@ -655,6 +656,8 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const PathSet & storePa
|
|||
|
||||
if (!dstStore->isValidPath(storePath)) {
|
||||
printInfo("copying '%s'...", storePath);
|
||||
MaintainCount<decltype(nrRunning)> mc(nrRunning);
|
||||
showProgress();
|
||||
copyStorePath(srcStore, dstStore, storePath, repair, checkSigs);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue