From 38ad34eb2f61a4b1ffd877fa44cf1d2865eb18b9 Mon Sep 17 00:00:00 2001 From: Qyriad Date: Mon, 17 Jun 2024 13:44:45 -0600 Subject: [PATCH] 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]: 243c0f18dae2a08ea0e46f7ff33277c63f7506d7 Change-Id: Ie734d1f638d45759d232805d7e3c2005f7dea483 --- src/libcmd/repl.cc | 2 +- src/libmain/progress-bar.cc | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 49865aa90..7269bdba5 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -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(); }); diff --git a/src/libmain/progress-bar.cc b/src/libmain/progress-bar.cc index d83b09cd4..e0c181d08 100644 --- a/src/libmain/progress-bar.cc +++ b/src/libmain/progress-bar.cc @@ -112,6 +112,8 @@ public: ~ProgressBar() { stop(); + updateThread.join(); + quitCV.notify_one(); } /* 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();