diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-18 23:01:58 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-18 23:01:58 +0000 |
commit | 3f8dcfe3fd8372ee8fc1b3233c7e9982d1a6915d (patch) | |
tree | 5a104db035aede46168326978dd3bc387f9e49a7 /src/nix/verify.cc | |
parent | d614166cb6864f2448b9e03f8dccccf301dc541e (diff) | |
parent | 669c3992e883414269d850bba5f00c59a1b207d0 (diff) |
Merge branch 'validPathInfo-temp' into validPathInfo-ca-proper-datatype
Diffstat (limited to 'src/nix/verify.cc')
-rw-r--r-- | src/nix/verify.cc | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/nix/verify.cc b/src/nix/verify.cc index 58ffc7e4b..bb5e4529b 100644 --- a/src/nix/verify.cc +++ b/src/nix/verify.cc @@ -59,7 +59,7 @@ struct CmdVerify : StorePathsCommand auto publicKeys = getDefaultPublicKeys(); - Activity act(*logger, ActivityType::VerifyPaths); + Activity act(*logger, actVerifyPaths); std::atomic<size_t> done{0}; std::atomic<size_t> untrusted{0}; @@ -77,7 +77,7 @@ struct CmdVerify : StorePathsCommand try { checkInterrupt(); - Activity act2(*logger, Verbosity::Info, ActivityType::Unknown, fmt("checking '%s'", storePath)); + Activity act2(*logger, lvlInfo, actUnknown, fmt("checking '%s'", storePath)); MaintainCount<std::atomic<size_t>> mcActive(active); update(); @@ -90,7 +90,7 @@ struct CmdVerify : StorePathsCommand if (!info->ca) hashSink = std::make_unique<HashSink>(*info->narHash.type); else - hashSink = std::make_unique<HashModuloSink>(*info->narHash.type, storePathToHash(store->printStorePath(info->path))); + hashSink = std::make_unique<HashModuloSink>(*info->narHash.type, std::string(info->path.hashPart())); store->narFromPath(info->path, *hashSink); @@ -98,12 +98,16 @@ struct CmdVerify : StorePathsCommand if (hash.first != info->narHash) { corrupted++; - act2.result(ResultType::CorruptedPath, store->printStorePath(info->path)); - printError( - "path '%s' was modified! expected hash '%s', got '%s'", - store->printStorePath(info->path), info->narHash.to_string(), hash.first.to_string()); + act2.result(resCorruptedPath, store->printStorePath(info->path)); + logError({ + .name = "Hash error - path modified", + .hint = hintfmt( + "path '%s' was modified! expected hash '%s', got '%s'", + store->printStorePath(info->path), + info->narHash.to_string(Base32, true), + hash.first.to_string(Base32, true)) + }); } - } if (!noTrust) { @@ -139,7 +143,7 @@ struct CmdVerify : StorePathsCommand doSigs(info2->sigs); } catch (InvalidPath &) { } catch (Error & e) { - printError(format(ANSI_RED "error:" ANSI_NORMAL " %s") % e.what()); + logError(e.info()); } } @@ -149,8 +153,13 @@ struct CmdVerify : StorePathsCommand if (!good) { untrusted++; - act2.result(ResultType::UntrustedPath, store->printStorePath(info->path)); - printError("path '%s' is untrusted", store->printStorePath(info->path)); + act2.result(resUntrustedPath, store->printStorePath(info->path)); + logError({ + .name = "Untrusted path", + .hint = hintfmt("path '%s' is untrusted", + store->printStorePath(info->path)) + }); + } } @@ -158,7 +167,7 @@ struct CmdVerify : StorePathsCommand done++; } catch (Error & e) { - printError(format(ANSI_RED "error:" ANSI_NORMAL " %s") % e.what()); + logError(e.info()); failed++; } |