diff options
author | Alois Wohlschlager <alois1@gmx-topmail.de> | 2024-06-29 15:03:44 +0200 |
---|---|---|
committer | Alois Wohlschlager <alois1@gmx-topmail.de> | 2024-07-01 18:19:34 +0200 |
commit | 0dd1d8ca1cdccfc620644a7f690ed35bcd2d1e74 (patch) | |
tree | f2cd3d4fa62e7956879d57cc041e6fe62836b36d /src/libcmd/repl.cc | |
parent | a55112898e23df10a7a0d2a0cd359996100e3512 (diff) |
tree-wide: unify progress bar inactive and paused states
Previously, the progress bar had two subtly different states in which the bar
would not actually render, both with their own shortcomings: inactive (which
was irreversible) and paused (reversible, but swallowing logs). Furthermore,
there was no way of resetting the statistics, so a very bad solution was
implemented (243c0f18dae2a08ea0e46f7ff33277c63f7506d7) that would create a new
logger for each line of the repl, leaking the previous one and discarding the
value of printBuildLogs. Finally, if stderr was not attached to a TTY, the
update thread was started even though the logger was not active, violating the
invariant required by the destructor (which is not observed because the logger
is leaked).
In this commit, the two aforementioned states are unified into a single one,
which can be exited again, correctly upholds the invariant that the update
thread is only running while the progress bar is active, and does not swallow
logs. The latter change in behavior is not expected to be a problems in the
rare cases where the paused state was used before, since other loggers (like
the simple one) don't exhibit it anyway. The startProgressBar/stopProgressBar
API is removed due to being a footgun, and a new method for properly resetting
the progress is added.
Co-Authored-By: Qyriad <qyriad@qyriad.me>
Change-Id: I2b7c3eb17d439cd0c16f7b896cfb61239ac7ff3a
Diffstat (limited to 'src/libcmd/repl.cc')
-rw-r--r-- | src/libcmd/repl.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 28341259c..39e89d999 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -32,7 +32,6 @@ #include "local-fs-store.hh" #include "signals.hh" #include "print.hh" -#include "progress-bar.hh" #include "gc-small-vector.hh" #include "users.hh" @@ -300,7 +299,7 @@ ReplExitStatus NixRepl::mainLoop() /* Stop the progress bar because it interferes with the display of the repl. */ - stopProgressBar(); + logger->pause(); std::string input; @@ -684,9 +683,10 @@ 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->resetProgress(); + logger->resume(); Finally stopLogger([&]() { - stopProgressBar(); + logger->pause(); }); state->store->buildPaths({ |