1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 00:51:47 +02:00

Support base-64 hashes

Also simplify the Hash API.

Fixes #1437.
This commit is contained in:
Eelco Dolstra 2017-07-04 14:47:59 +02:00
parent fe97c69898
commit c0015e87af
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
23 changed files with 205 additions and 213 deletions

View file

@ -212,7 +212,7 @@ static void opPrintFixedPath(Strings opFlags, Strings opArgs)
string name = *i++;
cout << format("%1%\n") %
store->makeFixedOutputPath(recursive, parseHash16or32(hashAlgo, hash), name);
store->makeFixedOutputPath(recursive, Hash(hash, hashAlgo), name);
}
@ -380,9 +380,9 @@ static void opQuery(Strings opFlags, Strings opArgs)
auto info = store->queryPathInfo(j);
if (query == qHash) {
assert(info->narHash.type == htSHA256);
cout << format("sha256:%1%\n") % printHash32(info->narHash);
cout << fmt("%s\n", info->narHash.to_string(Base32));
} else if (query == qSize)
cout << format("%1%\n") % info->narSize;
cout << fmt("%d\n", info->narSize);
}
}
break;
@ -734,7 +734,7 @@ static void opVerifyPath(Strings opFlags, Strings opArgs)
if (current.first != info->narHash) {
printError(
format("path %1% was modified! expected hash %2%, got %3%")
% path % printHash(info->narHash) % printHash(current.first));
% path % info->narHash.to_string() % current.first.to_string());
status = 1;
}
}