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:
parent
e0204f8d46
commit
451ebf24ce
18 changed files with 380 additions and 36 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue