diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-04-20 14:12:38 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-04-20 14:12:38 +0200 |
commit | 451ebf24ce532f8d59f929efd486104fcebf1aa6 (patch) | |
tree | 08bf43e0aad39626a1cc1ab9d5e638fdf90567b9 /src/libstore/nar-info.cc | |
parent | e0204f8d462041387651af388074491fd0bf36d6 (diff) |
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.
Diffstat (limited to 'src/libstore/nar-info.cc')
-rw-r--r-- | src/libstore/nar-info.cc | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/libstore/nar-info.cc b/src/libstore/nar-info.cc index 680facdcf..c0c5cecd1 100644 --- a/src/libstore/nar-info.cc +++ b/src/libstore/nar-info.cc @@ -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; -} - } |