repl: respect --print-build-logs

243c0f18d[1] allowed the logger's progress bar to display during repl
builds, but startProgressBar() re-creates the entire logger from
scratch, discarding the value of printBuildLogs (and leaking the
previous logger). In this commit, we instead move fully quitting the
logger into the destructor proper, and allow ProgressBar::resume() to
re-set the active state.

Internally, this should also allow the progress bar to be entirely
stopped and restarted at any time, without discarding the current
logger.

[1]: 243c0f18da

Change-Id: Ie734d1f638d45759d232805d7e3c2005f7dea483
This commit is contained in:
Qyriad 2024-06-17 13:50:40 -06:00
parent 6aead00a01
commit 05fd4c3ace
2 changed files with 4 additions and 3 deletions

View file

@ -622,7 +622,7 @@ ProcessLineResult NixRepl::processLine(std::string line)
// TODO: this only shows a progress bar for explicitly initiated builds,
// not eval-time fetching or builds performed for IFD.
// But we can't just show it everywhere, since that would erase partial output from evaluation.
startProgressBar();
logger->resume();
Finally stopLogger([&]() {
stopProgressBar();
});

View file

@ -112,6 +112,8 @@ public:
~ProgressBar()
{
stop();
quitCV.notify_one();
updateThread.join();
}
/* Called by destructor, can't be overridden */
@ -123,9 +125,7 @@ public:
state->active = false;
writeToStderr("\r\e[K");
updateCV.notify_one();
quitCV.notify_one();
}
updateThread.join();
}
void pause() override {
@ -135,6 +135,7 @@ public:
void resume() override {
state_.lock()->paused = false;
state_.lock()->active = isTTY;
writeToStderr("\r\e[K");
state_.lock()->haveUpdate = true;
updateCV.notify_one();