Use the StorePath-based cache interface

This commit is contained in:
Eelco Dolstra 2023-11-22 11:44:02 +01:00
parent 61b76f5f34
commit b1ab592f28

View file

@ -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));
@ -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;
}