mirror of
https://github.com/NixOS/nix.git
synced 2025-11-28 13:11:00 +01:00
Merge pull request #14647 from NixOS/fix-progress-bar
libmain: Fix download progress rendering
This commit is contained in:
commit
6cc44e4fdf
1 changed files with 13 additions and 9 deletions
|
|
@ -470,7 +470,8 @@ public:
|
|||
std::string res;
|
||||
|
||||
auto renderActivity =
|
||||
[&](ActivityType type, const std::string & itemFmt, const std::string & numberFmt = "%d", double unit = 1) {
|
||||
[&] [[nodiscard]] (
|
||||
ActivityType type, const std::string & itemFmt, const std::string & numberFmt = "%d", double unit = 1) {
|
||||
auto & act = state.activitiesByType[type];
|
||||
uint64_t done = act.done, expected = act.done, running = 0, failed = act.failed;
|
||||
for (auto & j : act.its) {
|
||||
|
|
@ -514,7 +515,7 @@ public:
|
|||
return s;
|
||||
};
|
||||
|
||||
auto renderSizeActivity = [&](ActivityType type, const std::string & itemFmt = "%s") {
|
||||
auto renderSizeActivity = [&] [[nodiscard]] (ActivityType type, const std::string & itemFmt = "%s") {
|
||||
auto & act = state.activitiesByType[type];
|
||||
uint64_t done = act.done, expected = act.done, running = 0, failed = act.failed;
|
||||
for (auto & j : act.its) {
|
||||
|
|
@ -573,9 +574,7 @@ public:
|
|||
return s;
|
||||
};
|
||||
|
||||
auto showActivity =
|
||||
[&](ActivityType type, const std::string & itemFmt, const std::string & numberFmt = "%d", double unit = 1) {
|
||||
auto s = renderActivity(type, itemFmt, numberFmt, unit);
|
||||
auto maybeAppendToResult = [&](std::string_view s) {
|
||||
if (s.empty())
|
||||
return;
|
||||
if (!res.empty())
|
||||
|
|
@ -583,6 +582,11 @@ public:
|
|||
res += s;
|
||||
};
|
||||
|
||||
auto showActivity =
|
||||
[&](ActivityType type, const std::string & itemFmt, const std::string & numberFmt = "%d", double unit = 1) {
|
||||
maybeAppendToResult(renderActivity(type, itemFmt, numberFmt, unit));
|
||||
};
|
||||
|
||||
showActivity(actBuilds, "%s built");
|
||||
|
||||
auto s1 = renderActivity(actCopyPaths, "%s copied");
|
||||
|
|
@ -602,7 +606,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
renderSizeActivity(actFileTransfer, "%s DL");
|
||||
maybeAppendToResult(renderSizeActivity(actFileTransfer, "%s DL"));
|
||||
|
||||
{
|
||||
auto s = renderActivity(actOptimiseStore, "%s paths optimised");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue