Skip to content

Commit e532a6a

Browse files
committed
When pausing the progress bar, print current activities
Otherwise the user won't see messages like "fetching Git repository" from the Git fetcher.
1 parent fed6a7e commit e532a6a

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/libmain/progress-bar.cc

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class ProgressBar : public Logger
5151
ActivityId parent;
5252
std::optional<std::string> name;
5353
std::chrono::time_point<std::chrono::steady_clock> startTime;
54+
bool logged = false;
5455
};
5556

5657
struct ActivitiesByType
@@ -142,8 +143,14 @@ class ProgressBar : public Logger
142143
return;
143144
}
144145

145-
if (state->active)
146+
if (state->active) {
146147
writeToStderr("\r\e[K");
148+
/* Show activities that were previously only shown on the
149+
progress bar. Otherwise the user won't know what's
150+
happening. */
151+
for (auto & act : state->activities)
152+
logActivity(*state, lvlNotice, act);
153+
}
147154
}
148155

149156
void resume() override
@@ -196,6 +203,14 @@ class ProgressBar : public Logger
196203
}
197204
}
198205

206+
void logActivity(State & state, Verbosity lvl, ActInfo & act)
207+
{
208+
if (!act.logged && lvl <= verbosity && !act.s.empty() && act.type != actBuildWaiting) {
209+
log(state, lvl, act.s + "...");
210+
act.logged = true;
211+
}
212+
}
213+
199214
void startActivity(
200215
ActivityId act,
201216
Verbosity lvl,
@@ -206,15 +221,14 @@ class ProgressBar : public Logger
206221
{
207222
auto state(state_.lock());
208223

209-
if (lvl <= verbosity && !s.empty() && type != actBuildWaiting)
210-
log(*state, lvl, s + "...");
211-
212224
state->activities.emplace_back(
213225
ActInfo{.s = s, .type = type, .parent = parent, .startTime = std::chrono::steady_clock::now()});
214226
auto i = std::prev(state->activities.end());
215227
state->its.emplace(act, i);
216228
state->activitiesByType[type].its.emplace(act, i);
217229

230+
logActivity(*state, lvl, *i);
231+
218232
if (type == actBuild) {
219233
std::string name(storePathToName(getS(fields, 0)));
220234
if (hasSuffix(name, ".drv"))

0 commit comments

Comments
 (0)