mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 12:06:01 +01:00
treewide: Remove getUri and replace with getHumanReadableURI where appropriate
The problem with old code was that it used getUri for both the `diskCache` as well as logging. This is really bad because it mixes the textual human readable representation with the caching. Also using getUri for the cache key is really problematic for the S3 store, since it doesn't include the `endpoint` in the cache key, so it's totally broken. This starts separating the logging / cache concerns by introducing a `getHumanReadableURI` that should only be used for logging. The caching logic now instead uses `getReference().render(/*withParams=*/false)` exclusively. This would need to be fixed in follow-ups, because that's really fragile and broken for some store types (but it was already broken before).
This commit is contained in:
parent
e6f3a193d8
commit
1b7ffa53af
20 changed files with 107 additions and 74 deletions
|
|
@ -59,7 +59,7 @@ void BinaryCacheStore::init()
|
|||
if (value != storeDir)
|
||||
throw Error(
|
||||
"binary cache '%s' is for Nix stores with prefix '%s', not '%s'",
|
||||
config.getUri(),
|
||||
config.getHumanReadableURI(),
|
||||
value,
|
||||
storeDir);
|
||||
} else if (name == "WantMassQuery") {
|
||||
|
|
@ -133,7 +133,9 @@ void BinaryCacheStore::writeNarInfo(ref<NarInfo> narInfo)
|
|||
|
||||
if (diskCache)
|
||||
diskCache->upsertNarInfo(
|
||||
config.getUri(), std::string(narInfo->path.hashPart()), std::shared_ptr<NarInfo>(narInfo));
|
||||
config.getReference().render(/*FIXME withParams=*/false),
|
||||
std::string(narInfo->path.hashPart()),
|
||||
std::shared_ptr<NarInfo>(narInfo));
|
||||
}
|
||||
|
||||
ref<const ValidPathInfo> BinaryCacheStore::addToStoreCommon(
|
||||
|
|
@ -431,7 +433,7 @@ void BinaryCacheStore::narFromPath(const StorePath & storePath, Sink & sink)
|
|||
void BinaryCacheStore::queryPathInfoUncached(
|
||||
const StorePath & storePath, Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept
|
||||
{
|
||||
auto uri = config.getUri();
|
||||
auto uri = config.getReference().render(/*FIXME withParams=*/false);
|
||||
auto storePathS = printStorePath(storePath);
|
||||
auto act = std::make_shared<Activity>(
|
||||
*logger,
|
||||
|
|
@ -531,7 +533,7 @@ void BinaryCacheStore::queryRealisationUncached(
|
|||
void BinaryCacheStore::registerDrvOutput(const Realisation & info)
|
||||
{
|
||||
if (diskCache)
|
||||
diskCache->upsertRealisation(config.getUri(), info);
|
||||
diskCache->upsertRealisation(config.getReference().render(/*FIXME withParams=*/false), info);
|
||||
auto filePath = realisationsPrefix + "/" + info.id.to_string() + ".doi";
|
||||
upsertFile(filePath, info.toJSON().dump(), "application/json");
|
||||
}
|
||||
|
|
@ -559,7 +561,7 @@ std::optional<std::string> BinaryCacheStore::getBuildLogExact(const StorePath &
|
|||
{
|
||||
auto logPath = "log/" + std::string(baseNameOf(printStorePath(path)));
|
||||
|
||||
debug("fetching build log from binary cache '%s/%s'", config.getUri(), logPath);
|
||||
debug("fetching build log from binary cache '%s/%s'", config.getHumanReadableURI(), logPath);
|
||||
|
||||
return getFile(logPath);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue