mirror of
https://github.com/NixOS/nix
synced 2025-06-25 14:51:16 +02:00
HttpBinaryCacheStore: Improve error message for unauthorized caches
Instead of the unhelpful warning: 'https://cache.flakehub.com' does not appear to be a binary cache you now get warning: unable to download 'https://cache.flakehub.com/nix-cache-info': HTTP error 401 response body: {"code":401,"error":"Unauthorized","message":"Unauthorized."}
This commit is contained in:
parent
ff00eebb16
commit
3b21ea40cc
3 changed files with 29 additions and 5 deletions
|
@ -194,6 +194,19 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
std::optional<std::string> getNixCacheInfo() override
|
||||
{
|
||||
try {
|
||||
auto result = getFileTransfer()->download(makeRequest(cacheInfoFile));
|
||||
return result.data;
|
||||
} catch (FileTransferError & e) {
|
||||
if (e.error == FileTransfer::NotFound)
|
||||
return std::nullopt;
|
||||
maybeDisable();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This isn't actually necessary read only. We support "upsert" now, so we
|
||||
* have a notion of authentication via HTTP POST/PUT.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue