mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 20:16:03 +01:00
Inline printHash16or32 and remove redundant helper (#13716)
Fixes ##13692 --------- Co-authored-by: John Ericson <git@JohnEricson.me> Co-authored-by: Sergei Zimmerman <sergei@zimmerman.foo>
This commit is contained in:
parent
d4c6f24e9f
commit
d2022189a1
3 changed files with 3 additions and 12 deletions
|
|
@ -60,12 +60,6 @@ std::strong_ordering Hash::operator<=>(const Hash & h) const noexcept
|
||||||
return std::strong_ordering::equivalent;
|
return std::strong_ordering::equivalent;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string printHash16or32(const Hash & hash)
|
|
||||||
{
|
|
||||||
assert(static_cast<char>(hash.algo));
|
|
||||||
return hash.to_string(hash.algo == HashAlgorithm::MD5 ? HashFormat::Base16 : HashFormat::Nix32, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Hash::to_string(HashFormat hashFormat, bool includeAlgo) const
|
std::string Hash::to_string(HashFormat hashFormat, bool includeAlgo) const
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
|
||||||
|
|
@ -133,11 +133,6 @@ public:
|
||||||
*/
|
*/
|
||||||
Hash newHashAllowEmpty(std::string_view hashStr, std::optional<HashAlgorithm> ha);
|
Hash newHashAllowEmpty(std::string_view hashStr, std::optional<HashAlgorithm> ha);
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a hash in base-16 if it's MD5, or base-32 otherwise.
|
|
||||||
*/
|
|
||||||
std::string printHash16or32(const Hash & hash);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the hash of the given string.
|
* Compute the hash of the given string.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,9 @@ static int main_nix_prefetch_url(int argc, char ** argv)
|
||||||
if (!printPath)
|
if (!printPath)
|
||||||
printInfo("path is '%s'", store->printStorePath(storePath));
|
printInfo("path is '%s'", store->printStorePath(storePath));
|
||||||
|
|
||||||
logger->cout(printHash16or32(hash));
|
assert(static_cast<char>(hash.algo));
|
||||||
|
logger->cout(hash.to_string(hash.algo == HashAlgorithm::MD5 ? HashFormat::Base16 : HashFormat::Nix32, false));
|
||||||
|
|
||||||
if (printPath)
|
if (printPath)
|
||||||
logger->cout(store->printStorePath(storePath));
|
logger->cout(store->printStorePath(storePath));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue