repl: respect --print-build-logs & fix memory leak

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 call logger->pause() and
logger->resume().

[1]: 243c0f18da

Change-Id: Ie734d1f638d45759d232805d7e3c2005f7dea483
This commit is contained in:
Qyriad 2024-06-18 22:15:16 -06:00
parent 6aead00a01
commit dac2045d08

View file

@ -268,7 +268,7 @@ ReplExitStatus NixRepl::mainLoop()
/* Stop the progress bar because it interferes with the display of
the repl. */
stopProgressBar();
logger->pause();
std::string input;
@ -622,9 +622,9 @@ 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();
logger->pause();
});
state->store->buildPaths({