Skip to content

Commit

Permalink
Use the StorePath-based cache interface
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Nov 22, 2023
1 parent 61b76f5 commit b1ab592
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/libfetchers/input-accessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@ StorePath InputAccessor::fetchToStore(
{"method", (uint8_t) method},
{"path", path.abs()}
};
if (auto res = fetchers::getCache()->lookup(*cacheKey)) {
StorePath storePath{fetchers::getStrAttr(*res, "storePath")};
if (store->isValidPath(storePath)) {
debug("store path cache hit for '%s'", showPath(path));
return storePath;
}
if (auto res = fetchers::getCache()->lookup(store, *cacheKey)) {
debug("store path cache hit for '%s'", showPath(path));
return res->second;
}
} else
debug("source path '%s' is uncacheable", showPath(path));
Expand All @@ -51,9 +48,7 @@ StorePath InputAccessor::fetchToStore(
: store->addToStoreFromDump(*source, name, method, htSHA256, repair);

if (cacheKey)
fetchers::getCache()->upsert(
*cacheKey,
fetchers::Attrs{{"storePath", std::string(storePath.to_string())}});
fetchers::getCache()->add(store, *cacheKey, {}, storePath, true);

return storePath;
}
Expand Down

0 comments on commit b1ab592

Please sign in to comment.