mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Merge pull request #14209 from lovesegfault/curl-based-s3-pieces-fix
fix(libstore): improve http-binary-cache-store S3 compatibility
This commit is contained in:
commit
97e770ad01
1 changed files with 16 additions and 4 deletions
|
|
@ -78,7 +78,11 @@ public:
|
|||
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 {
|
||||
|
|
@ -87,8 +91,7 @@ public:
|
|||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -184,7 +187,16 @@ protected:
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue