From 07ba1eb67ebf34f29c36577d1f272c587f379b44 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 19 Nov 2020 13:29:11 +0100 Subject: [PATCH] Progress bar: Handle verify --- src/libmain/progress-bar.cc | 44 +++++++++++++++++++++++++++++++++++-- src/libutil/logging.hh | 1 + src/nix/verify.cc | 4 +++- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/libmain/progress-bar.cc b/src/libmain/progress-bar.cc index 28692f2a1..dea1008c4 100644 --- a/src/libmain/progress-bar.cc +++ b/src/libmain/progress-bar.cc @@ -122,6 +122,7 @@ private: idQueryMissing, idCopyPaths, idBuilds, + idVerifyPaths, idStatus, idQuit }; @@ -448,12 +449,16 @@ public: i->ignored = true; } + if (type == actVerifyPath) + i->s = getS(fields, 0); + if (type == actFileTransfer || (type == actCopyPath && hasAncestor(*state, actSubstitute, parent)) // FIXME? || type == actBuild || type == actSubstitute || type == actLockFlake - || type == actQueryMissing) + || type == actQueryMissing + || type == actVerifyPath) i->visible = false; if (type == actBuild) @@ -613,6 +618,8 @@ public: auto doneMark = ANSI_GREEN "✓"; + auto failMark = ANSI_RED "✗"; + if (state.activitiesByType.count(actEvaluate)) { state.statusLines.insert_or_assign({idEvaluate, 0}, fmt("%s Evaluate", @@ -719,7 +726,7 @@ public: {idBuilds, n++}, fmt("%s Build %d / %d derivations", builds.failed - ? ANSI_RED "✗" + ? failMark : builds.running || builds.done < builds.expected ? busyMark : doneMark, @@ -742,6 +749,39 @@ public: state.statusLines.insert_or_assign({idBuilds, n++}, ""); } + + auto verify = getActivityStats(state.activitiesByType[actVerifyPaths]); + + if (verify.done || verify.expected) { + removeStatusLines(state, idVerifyPaths); + + auto bad = state.corruptedPaths + state.untrustedPaths + verify.failed; + + size_t n = 0; + state.statusLines.insert_or_assign( + {idVerifyPaths, n++}, + fmt("%s Verify %d / %d paths", + verify.done < verify.expected + ? busyMark + : bad + ? failMark + : doneMark, + verify.done, verify.expected) + + (state.corruptedPaths ? fmt(", %d corrupted", state.corruptedPaths) : "") + + (state.untrustedPaths ? fmt(", %d untrusted", state.untrustedPaths) : "") + + (verify.failed ? fmt(", %d failed", verify.failed) : "") + ); + + state.statusLines.insert_or_assign({idVerifyPaths, n++}, + fmt(" %s", renderBar(verify.done - bad, bad, verify.running, verify.expected))); + + for (auto & build : state.activitiesByType[actVerifyPath].its) { + state.statusLines.insert_or_assign({idVerifyPaths, n++}, + fmt(ANSI_BOLD " ‣ %s", build.second->s)); + } + + state.statusLines.insert_or_assign({idVerifyPaths, n++}, ""); + } } void draw(State & state, std::optional msg = {}) diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh index fca23fc7c..d02bc5820 100644 --- a/src/libutil/logging.hh +++ b/src/libutil/logging.hh @@ -23,6 +23,7 @@ typedef enum { actEvaluate = 112, actLockFlake = 113, actQueryMissing = 114, + actVerifyPath = 115, } ActivityType; typedef enum { diff --git a/src/nix/verify.cc b/src/nix/verify.cc index 16d42349f..1de02509c 100644 --- a/src/nix/verify.cc +++ b/src/nix/verify.cc @@ -76,7 +76,9 @@ struct CmdVerify : StorePathsCommand // Note: info->path can be different from storePath // for binary cache stores when using --all (since we // can't enumerate names efficiently). - Activity act2(*logger, lvlInfo, actUnknown, fmt("checking '%s'", store->printStorePath(info->path))); + Activity act2(*logger, lvlInfo, actVerifyPath, + fmt("checking '%s'", store->printStorePath(info->path)), + {store->printStorePath(info->path)}); if (!noContents) {