mirror of
https://github.com/NixOS/nix.git
synced 2025-11-28 13:11:00 +01:00
libmain: Fix download progress rendering
This was broken in https://github.com/NixOS/nix/pull/14423 accidentally. Add [[nodiscard]] to prevent such mistakes in the future.
This commit is contained in:
parent
423e732b22
commit
4031343e44
1 changed files with 13 additions and 9 deletions
|
|
@ -470,7 +470,8 @@ public:
|
||||||
std::string res;
|
std::string res;
|
||||||
|
|
||||||
auto renderActivity =
|
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];
|
auto & act = state.activitiesByType[type];
|
||||||
uint64_t done = act.done, expected = act.done, running = 0, failed = act.failed;
|
uint64_t done = act.done, expected = act.done, running = 0, failed = act.failed;
|
||||||
for (auto & j : act.its) {
|
for (auto & j : act.its) {
|
||||||
|
|
@ -514,7 +515,7 @@ public:
|
||||||
return s;
|
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];
|
auto & act = state.activitiesByType[type];
|
||||||
uint64_t done = act.done, expected = act.done, running = 0, failed = act.failed;
|
uint64_t done = act.done, expected = act.done, running = 0, failed = act.failed;
|
||||||
for (auto & j : act.its) {
|
for (auto & j : act.its) {
|
||||||
|
|
@ -573,14 +574,17 @@ public:
|
||||||
return s;
|
return s;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto maybeAppendToResult = [&](std::string_view s) {
|
||||||
|
if (s.empty())
|
||||||
|
return;
|
||||||
|
if (!res.empty())
|
||||||
|
res += ", ";
|
||||||
|
res += s;
|
||||||
|
};
|
||||||
|
|
||||||
auto showActivity =
|
auto showActivity =
|
||||||
[&](ActivityType type, const std::string & itemFmt, const std::string & numberFmt = "%d", double unit = 1) {
|
[&](ActivityType type, const std::string & itemFmt, const std::string & numberFmt = "%d", double unit = 1) {
|
||||||
auto s = renderActivity(type, itemFmt, numberFmt, unit);
|
maybeAppendToResult(renderActivity(type, itemFmt, numberFmt, unit));
|
||||||
if (s.empty())
|
|
||||||
return;
|
|
||||||
if (!res.empty())
|
|
||||||
res += ", ";
|
|
||||||
res += s;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
showActivity(actBuilds, "%s built");
|
showActivity(actBuilds, "%s built");
|
||||||
|
|
@ -602,7 +606,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSizeActivity(actFileTransfer, "%s DL");
|
maybeAppendToResult(renderSizeActivity(actFileTransfer, "%s DL"));
|
||||||
|
|
||||||
{
|
{
|
||||||
auto s = renderActivity(actOptimiseStore, "%s paths optimised");
|
auto s = renderActivity(actOptimiseStore, "%s paths optimised");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue