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

Cache path info lookups in SQLite

This re-implements the binary cache database in C++, allowing it to be
used by other Store backends, in particular the S3 backend.
This commit is contained in:
Eelco Dolstra 2016-04-20 14:12:38 +02:00
parent e0204f8d46
commit 451ebf24ce
18 changed files with 380 additions and 36 deletions

View file

@ -5,16 +5,16 @@ namespace nix {
NarInfo::NarInfo(const std::string & s, const std::string & whence)
{
auto corrupt = [&]() {
auto corrupt = [&]() [[noreturn]] {
throw Error("NAR info file %1% is corrupt");
};
auto parseHashField = [&](const string & s) {
string::size_type colon = s.find(':');
if (colon == string::npos) corrupt();
HashType ht = parseHashType(string(s, 0, colon));
if (ht == htUnknown) corrupt();
return parseHash16or32(ht, string(s, colon + 1));
try {
return parseHash(s);
} catch (BadHash &) {
corrupt();
}
};
size_t pos = 0;
@ -103,12 +103,4 @@ std::string NarInfo::to_string() const
return res;
}
Strings NarInfo::shortRefs() const
{
Strings refs;
for (auto & r : references)
refs.push_back(baseNameOf(r));
return refs;
}
}