Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/libstore/http-binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ class HttpBinaryCacheStore : public virtual BinaryCacheStore
void init() override
{
// FIXME: do this lazily?
if (auto cacheInfo = diskCache->upToDateCacheExists(config->cacheUri.to_string())) {
// For consistent cache key handling, use the reference without parameters
// This matches what's used in Store::queryPathInfo() lookups
auto cacheKey = config->getReference().render(/*withParams=*/false);

if (auto cacheInfo = diskCache->upToDateCacheExists(cacheKey)) {
config->wantMassQuery.setDefault(cacheInfo->wantMassQuery);
config->priority.setDefault(cacheInfo->priority);
} else {
Expand All @@ -87,8 +91,7 @@ class HttpBinaryCacheStore : public virtual BinaryCacheStore
} catch (UploadToHTTP &) {
throw Error("'%s' does not appear to be a binary cache", config->cacheUri.to_string());
}
diskCache->createCache(
config->cacheUri.to_string(), config->storeDir, config->wantMassQuery, config->priority);
diskCache->createCache(cacheKey, config->storeDir, config->wantMassQuery, config->priority);
}
}

Expand Down Expand Up @@ -184,7 +187,16 @@ class HttpBinaryCacheStore : public virtual BinaryCacheStore
field which is
`nar/15f99rdaf26k39knmzry4xd0d97wp6yfpnfk1z9avakis7ipb9yg.nar?hash=zphkqn2wg8mnvbkixnl2aadkbn0rcnfj`
(note the query param) and that gets passed here. */
return FileTransferRequest(parseURLRelative(path, cacheUriWithTrailingSlash));
auto result = parseURLRelative(path, cacheUriWithTrailingSlash);

/* For S3 URLs, preserve query parameters from the base URL when the
relative path doesn't have its own query parameters. This is needed
to preserve S3-specific parameters like endpoint and region. */
if (config->cacheUri.scheme == "s3" && result.query.empty()) {
result.query = config->cacheUri.query;
}

return FileTransferRequest(result);
}

void getFile(const std::string & path, Sink & sink) override
Expand Down
Loading