Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b66234134fad
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d5d19582ef24
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on May 10, 2021

  1. Remove useless parents

    I never remember the exact syntax of the `switch` statement
    thufschmitt committed May 10, 2021

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    jonringer Jonathan Ringer
    Copy the full SHA
    ab96c1e View commit details
  2. Copy the full SHA
    d5d1958 View commit details
Showing with 13 additions and 14 deletions.
  1. +3 −3 src/libstore/binary-cache-store.cc
  2. +10 −11 src/libstore/nar-info-disk-cache.cc
6 changes: 3 additions & 3 deletions src/libstore/binary-cache-store.cc
Original file line number Diff line number Diff line change
@@ -454,13 +454,13 @@ std::optional<const Realisation> BinaryCacheStore::queryRealisation(const DrvOut
auto [cacheOutcome, maybeCachedRealisation] =
diskCache->lookupRealisation(getUri(), id);
switch (cacheOutcome) {
case (NarInfoDiskCache::oValid):
case NarInfoDiskCache::oValid:
debug("Returning a cached realisation for %s", id.to_string());
return *maybeCachedRealisation;
case (NarInfoDiskCache::oInvalid):
case NarInfoDiskCache::oInvalid:
debug("Returning a cached missing realisation for %s", id.to_string());
return {};
case (NarInfoDiskCache::oUnknown):
case NarInfoDiskCache::oUnknown:
break;
}
}
21 changes: 10 additions & 11 deletions src/libstore/nar-info-disk-cache.cc
Original file line number Diff line number Diff line change
@@ -42,9 +42,8 @@ create table if not exists NARs (
create table if not exists Realisations (
cache integer not null,
outputId text not null,
content blob, -- Json serialisation of the realisation, or empty if present is true
content blob, -- Json serialisation of the realisation, or null if the realisation is absent
timestamp integer not null,
present integer not null,
primary key (cache, outputId),
foreign key (cache) references BinaryCaches(id) on delete cascade
);
@@ -113,22 +112,22 @@ class NarInfoDiskCacheImpl : public NarInfoDiskCache

state->insertRealisation.create(state->db,
R"(
insert or replace into Realisations(cache, outputId, content, timestamp, present)
values (?, ?, ?, ?, 1)
insert or replace into Realisations(cache, outputId, content, timestamp)
values (?, ?, ?, ?)
)");

state->insertMissingRealisation.create(state->db,
R"(
insert or replace into Realisations(cache, outputId, timestamp, present)
values (?, ?, ?, 0)
insert or replace into Realisations(cache, outputId, timestamp)
values (?, ?, ?)
)");

state->queryRealisation.create(state->db,
R"(
select present, content from Realisations
select content from Realisations
where cache = ? and outputId = ? and
((present = 0 and timestamp > ?) or
(present = 1 and timestamp > ?))
((content is null and timestamp > ?) or
(content is not null and timestamp > ?))
)");

/* Periodically purge expired entries from the database. */
@@ -265,12 +264,12 @@ class NarInfoDiskCacheImpl : public NarInfoDiskCache
if (!queryRealisation.next())
return {oUnknown, 0};

if (queryRealisation.getInt(0) == 0)
if (queryRealisation.isNull(0))
return {oInvalid, 0};

auto realisation =
std::make_shared<Realisation>(Realisation::fromJSON(
nlohmann::json::parse(queryRealisation.getStr(1)),
nlohmann::json::parse(queryRealisation.getStr(0)),
"Local disk cache"));

return {oValid, realisation};