From c2cab207320672fb6ed4af40a99fc9082ff55234 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 16 Aug 2017 19:23:46 +0200 Subject: nix verify: Restore the progress indicator --- src/nix/verify.cc | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/nix/verify.cc') diff --git a/src/nix/verify.cc b/src/nix/verify.cc index 0d9739314b53..7156341396d3 100644 --- a/src/nix/verify.cc +++ b/src/nix/verify.cc @@ -61,16 +61,17 @@ struct CmdVerify : StorePathsCommand auto publicKeys = getDefaultPublicKeys(); + Activity act(*logger, actVerifyPaths); + std::atomic done{0}; std::atomic untrusted{0}; std::atomic corrupted{0}; std::atomic failed{0}; + std::atomic active{0}; - std::string doneLabel("paths checked"); - std::string untrustedLabel("untrusted"); - std::string corruptedLabel("corrupted"); - std::string failedLabel("failed"); - //logger->setExpected(doneLabel, storePaths.size()); + auto update = [&]() { + act.progress(done, storePaths.size(), active, failed); + }; ThreadPool pool; @@ -78,7 +79,10 @@ struct CmdVerify : StorePathsCommand try { checkInterrupt(); - //Activity act(*logger, lvlInfo, format("checking '%s'") % storePath); + Activity act2(*logger, actUnknown, fmt("checking '%s'", storePath)); + + MaintainCount> mcActive(active); + update(); auto info = store->queryPathInfo(storePath); @@ -90,8 +94,8 @@ struct CmdVerify : StorePathsCommand auto hash = sink.finish(); if (hash.first != info->narHash) { - //logger->incProgress(corruptedLabel); - corrupted = 1; + corrupted++; + act2.result(resCorruptedPath, info->path); printError( format("path '%s' was modified! expected hash '%s', got '%s'") % info->path % info->narHash.to_string() % hash.first.to_string()); @@ -142,21 +146,21 @@ struct CmdVerify : StorePathsCommand } if (!good) { - //logger->incProgress(untrustedLabel); untrusted++; + act2.result(resUntrustedPath, info->path); printError(format("path '%s' is untrusted") % info->path); } } - //logger->incProgress(doneLabel); done++; } catch (Error & e) { printError(format(ANSI_RED "error:" ANSI_NORMAL " %s") % e.what()); - //logger->incProgress(failedLabel); failed++; } + + update(); }; for (auto & storePath : storePaths) @@ -164,9 +168,6 @@ struct CmdVerify : StorePathsCommand pool.process(); - printInfo(format("%d paths checked, %d untrusted, %d corrupted, %d failed") - % done % untrusted % corrupted % failed); - throw Exit( (corrupted ? 1 : 0) | (untrusted ? 2 : 0) | -- cgit 1.4.1