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