Rename ValidPathInfo::hash -> narHash for consistency
This commit is contained in:
parent
92063851b1
commit
5ac27053e9
|
@ -108,7 +108,7 @@ SV * queryPathInfo(char * path, int base32)
|
|||
XPUSHs(&PL_sv_undef);
|
||||
else
|
||||
XPUSHs(sv_2mortal(newSVpv(info.deriver.c_str(), 0)));
|
||||
string s = "sha256:" + (base32 ? printHash32(info.hash) : printHash(info.hash));
|
||||
string s = "sha256:" + (base32 ? printHash32(info.narHash) : printHash(info.narHash));
|
||||
XPUSHs(sv_2mortal(newSVpv(s.c_str(), 0)));
|
||||
mXPUSHi(info.registrationTime);
|
||||
mXPUSHi(info.narSize);
|
||||
|
|
|
@ -2735,7 +2735,7 @@ void DerivationGoal::registerOutputs()
|
|||
if (buildMode == bmCheck) {
|
||||
if (!worker.store.isValidPath(path)) continue;
|
||||
ValidPathInfo info = worker.store.queryPathInfo(path);
|
||||
if (hash.first != info.hash) {
|
||||
if (hash.first != info.narHash) {
|
||||
if (settings.keepFailed) {
|
||||
Path dst = path + checkSuffix;
|
||||
if (pathExists(dst)) deletePath(dst);
|
||||
|
@ -2799,7 +2799,7 @@ void DerivationGoal::registerOutputs()
|
|||
|
||||
ValidPathInfo info;
|
||||
info.path = path;
|
||||
info.hash = hash.first;
|
||||
info.narHash = hash.first;
|
||||
info.narSize = hash.second;
|
||||
info.references = references;
|
||||
info.deriver = drvPath;
|
||||
|
@ -3369,7 +3369,7 @@ void SubstitutionGoal::finished()
|
|||
|
||||
ValidPathInfo info2;
|
||||
info2.path = storePath;
|
||||
info2.hash = hash.first;
|
||||
info2.narHash = hash.first;
|
||||
info2.narSize = hash.second;
|
||||
info2.references = info.references;
|
||||
info2.deriver = info.deriver;
|
||||
|
|
|
@ -694,7 +694,7 @@ unsigned long long LocalStore::addValidPath(const ValidPathInfo & info, bool che
|
|||
{
|
||||
SQLiteStmtUse use(stmtRegisterValidPath);
|
||||
stmtRegisterValidPath.bind(info.path);
|
||||
stmtRegisterValidPath.bind("sha256:" + printHash(info.hash));
|
||||
stmtRegisterValidPath.bind("sha256:" + printHash(info.narHash));
|
||||
stmtRegisterValidPath.bind(info.registrationTime == 0 ? time(0) : info.registrationTime);
|
||||
if (info.deriver != "")
|
||||
stmtRegisterValidPath.bind(info.deriver);
|
||||
|
@ -845,7 +845,7 @@ ValidPathInfo LocalStore::queryPathInfo(const Path & path)
|
|||
|
||||
const char * s = (const char *) sqlite3_column_text(stmtQueryPathInfo, 1);
|
||||
assert(s);
|
||||
info.hash = parseHashField(path, s);
|
||||
info.narHash = parseHashField(path, s);
|
||||
|
||||
info.registrationTime = sqlite3_column_int(stmtQueryPathInfo, 2);
|
||||
|
||||
|
@ -883,7 +883,7 @@ void LocalStore::updatePathInfo(const ValidPathInfo & info)
|
|||
stmtUpdatePathInfo.bind64(info.narSize);
|
||||
else
|
||||
stmtUpdatePathInfo.bind(); // null
|
||||
stmtUpdatePathInfo.bind("sha256:" + printHash(info.hash));
|
||||
stmtUpdatePathInfo.bind("sha256:" + printHash(info.narHash));
|
||||
stmtUpdatePathInfo.bind(info.path);
|
||||
if (sqlite3_step(stmtUpdatePathInfo) != SQLITE_DONE)
|
||||
throwSQLiteError(db, format("updating info of path ‘%1%’ in database") % info.path);
|
||||
|
@ -1274,7 +1274,7 @@ void LocalStore::querySubstitutablePathInfos(const PathSet & paths,
|
|||
|
||||
Hash LocalStore::queryPathHash(const Path & path)
|
||||
{
|
||||
return queryPathInfo(path).hash;
|
||||
return queryPathInfo(path).narHash;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1298,7 +1298,7 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos)
|
|||
PathSet paths;
|
||||
|
||||
for (auto & i : infos) {
|
||||
assert(i.hash.type == htSHA256);
|
||||
assert(i.narHash.type == htSHA256);
|
||||
if (isValidPath_(i.path))
|
||||
updatePathInfo(i);
|
||||
else
|
||||
|
@ -1397,7 +1397,7 @@ Path LocalStore::addToStoreFromDump(const string & dump, const string & name,
|
|||
|
||||
ValidPathInfo info;
|
||||
info.path = dstPath;
|
||||
info.hash = hash.first;
|
||||
info.narHash = hash.first;
|
||||
info.narSize = hash.second;
|
||||
registerValidPath(info);
|
||||
}
|
||||
|
@ -1453,7 +1453,7 @@ Path LocalStore::addTextToStore(const string & name, const string & s,
|
|||
|
||||
ValidPathInfo info;
|
||||
info.path = dstPath;
|
||||
info.hash = hash.first;
|
||||
info.narHash = hash.first;
|
||||
info.narSize = hash.second;
|
||||
info.references = references;
|
||||
registerValidPath(info);
|
||||
|
@ -1680,7 +1680,7 @@ Path LocalStore::importPath(bool requireSignature, Source & source)
|
|||
|
||||
ValidPathInfo info;
|
||||
info.path = dstPath;
|
||||
info.hash = hash.first;
|
||||
info.narHash = hash.first;
|
||||
info.narSize = hash.second;
|
||||
info.references = references;
|
||||
info.deriver = deriver != "" && isValidPath(deriver) ? deriver : "";
|
||||
|
@ -1764,21 +1764,21 @@ bool LocalStore::verifyStore(bool checkContents, bool repair)
|
|||
|
||||
/* Check the content hash (optionally - slow). */
|
||||
printMsg(lvlTalkative, format("checking contents of ‘%1%’") % i);
|
||||
HashResult current = hashPath(info.hash.type, i);
|
||||
HashResult current = hashPath(info.narHash.type, i);
|
||||
|
||||
if (info.hash != nullHash && info.hash != current.first) {
|
||||
if (info.narHash != nullHash && info.narHash != current.first) {
|
||||
printMsg(lvlError, format("path ‘%1%’ was modified! "
|
||||
"expected hash ‘%2%’, got ‘%3%’")
|
||||
% i % printHash(info.hash) % printHash(current.first));
|
||||
% i % printHash(info.narHash) % printHash(current.first));
|
||||
if (repair) repairPath(i); else errors = true;
|
||||
} else {
|
||||
|
||||
bool update = false;
|
||||
|
||||
/* Fill in missing hashes. */
|
||||
if (info.hash == nullHash) {
|
||||
if (info.narHash == nullHash) {
|
||||
printMsg(lvlError, format("fixing missing hash on ‘%1%’") % i);
|
||||
info.hash = current.first;
|
||||
info.narHash = current.first;
|
||||
update = true;
|
||||
}
|
||||
|
||||
|
@ -1867,9 +1867,9 @@ bool LocalStore::pathContentsGood(const Path & path)
|
|||
if (!pathExists(path))
|
||||
res = false;
|
||||
else {
|
||||
HashResult current = hashPath(info.hash.type, path);
|
||||
HashResult current = hashPath(info.narHash.type, path);
|
||||
Hash nullHash(htSHA256);
|
||||
res = info.hash == nullHash || info.hash == current.first;
|
||||
res = info.narHash == nullHash || info.narHash == current.first;
|
||||
}
|
||||
pathContentsGoodCache[path] = res;
|
||||
if (!res) printMsg(lvlError, format("path ‘%1%’ is corrupted or missing!") % path);
|
||||
|
@ -1921,7 +1921,7 @@ ValidPathInfo LocalStore::queryPathInfoOld(const Path & path)
|
|||
} else if (name == "Deriver") {
|
||||
res.deriver = value;
|
||||
} else if (name == "Hash") {
|
||||
res.hash = parseHashField(path, value);
|
||||
res.narHash = parseHashField(path, value);
|
||||
} else if (name == "Registered-At") {
|
||||
int n = 0;
|
||||
string2Int(value, n);
|
||||
|
|
|
@ -273,7 +273,7 @@ ValidPathInfo RemoteStore::queryPathInfo(const Path & path)
|
|||
info.path = path;
|
||||
info.deriver = readString(from);
|
||||
if (info.deriver != "") assertStorePath(info.deriver);
|
||||
info.hash = parseHash(htSHA256, readString(from));
|
||||
info.narHash = parseHash(htSHA256, readString(from));
|
||||
info.references = readStorePaths<PathSet>(from);
|
||||
info.registrationTime = readInt(from);
|
||||
info.narSize = readLongLong(from);
|
||||
|
|
|
@ -245,7 +245,7 @@ string Store::makeValidityRegistration(const PathSet & paths,
|
|||
ValidPathInfo info = queryPathInfo(i);
|
||||
|
||||
if (showHash) {
|
||||
s += printHash(info.hash) + "\n";
|
||||
s += printHash(info.narHash) + "\n";
|
||||
s += (format("%1%\n") % info.narSize).str();
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ ValidPathInfo decodeValidPathInfo(std::istream & str, bool hashGiven)
|
|||
if (hashGiven) {
|
||||
string s;
|
||||
getline(str, s);
|
||||
info.hash = parseHash(htSHA256, s);
|
||||
info.narHash = parseHash(htSHA256, s);
|
||||
getline(str, s);
|
||||
if (!string2Int(s, info.narSize)) throw Error("number expected");
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ struct ValidPathInfo
|
|||
{
|
||||
Path path;
|
||||
Path deriver;
|
||||
Hash hash;
|
||||
Hash narHash;
|
||||
PathSet references;
|
||||
time_t registrationTime = 0;
|
||||
unsigned long long narSize = 0; // 0 = unknown
|
||||
|
@ -102,7 +102,7 @@ struct ValidPathInfo
|
|||
{
|
||||
return
|
||||
path == i.path
|
||||
&& hash == i.hash
|
||||
&& narHash == i.narHash
|
||||
&& references == i.references;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -515,7 +515,7 @@ static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVe
|
|||
startWork();
|
||||
ValidPathInfo info = store->queryPathInfo(path);
|
||||
stopWork();
|
||||
to << info.deriver << printHash(info.hash) << info.references
|
||||
to << info.deriver << printHash(info.narHash) << info.references
|
||||
<< info.registrationTime << info.narSize;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -374,8 +374,8 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
|||
for (auto & j : paths) {
|
||||
ValidPathInfo info = store->queryPathInfo(j);
|
||||
if (query == qHash) {
|
||||
assert(info.hash.type == htSHA256);
|
||||
cout << format("sha256:%1%\n") % printHash32(info.hash);
|
||||
assert(info.narHash.type == htSHA256);
|
||||
cout << format("sha256:%1%\n") % printHash32(info.narHash);
|
||||
} else if (query == qSize)
|
||||
cout << format("%1%\n") % info.narSize;
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ static void registerValidity(bool reregister, bool hashGiven, bool canonicalise)
|
|||
canonicalisePathMetaData(info.path, -1);
|
||||
if (!hashGiven) {
|
||||
HashResult hash = hashPath(htSHA256, info.path);
|
||||
info.hash = hash.first;
|
||||
info.narHash = hash.first;
|
||||
info.narSize = hash.second;
|
||||
}
|
||||
infos.push_back(info);
|
||||
|
@ -783,11 +783,11 @@ static void opVerifyPath(Strings opFlags, Strings opArgs)
|
|||
Path path = followLinksToStorePath(i);
|
||||
printMsg(lvlTalkative, format("checking path ‘%1%’...") % path);
|
||||
ValidPathInfo info = store->queryPathInfo(path);
|
||||
HashResult current = hashPath(info.hash.type, path);
|
||||
if (current.first != info.hash) {
|
||||
HashResult current = hashPath(info.narHash.type, path);
|
||||
if (current.first != info.narHash) {
|
||||
printMsg(lvlError,
|
||||
format("path ‘%1%’ was modified! expected hash ‘%2%’, got ‘%3%’")
|
||||
% path % printHash(info.hash) % printHash(current.first));
|
||||
% path % printHash(info.narHash) % printHash(current.first));
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue