mirror of
https://github.com/NixOS/nix.git
synced 2025-11-18 00:12:43 +01:00
libfetchers/github: Use getFSAccessor for downloadFile result
We should use proper abstractions for reading files from the store. E.g. this caused errors when trying to download github flakes into an in-memory store in #14023.
This commit is contained in:
parent
d8d1fb0e34
commit
e04381edbd
1 changed files with 6 additions and 4 deletions
|
|
@ -398,8 +398,9 @@ struct GitHubInputScheme : GitArchiveInputScheme
|
|||
|
||||
Headers headers = makeHeadersWithAuthTokens(*input.settings, host, input);
|
||||
|
||||
auto json = nlohmann::json::parse(
|
||||
readFile(store->toRealPath(downloadFile(store, *input.settings, url, "source", headers).storePath)));
|
||||
auto accessor = store->getFSAccessor();
|
||||
auto downloadResult = downloadFile(store, *input.settings, url, "source", headers);
|
||||
auto json = nlohmann::json::parse(accessor->readFile(CanonPath(downloadResult.storePath.to_string())));
|
||||
|
||||
return RefInfo{
|
||||
.rev = Hash::parseAny(std::string{json["sha"]}, HashAlgorithm::SHA1),
|
||||
|
|
@ -472,8 +473,9 @@ struct GitLabInputScheme : GitArchiveInputScheme
|
|||
|
||||
Headers headers = makeHeadersWithAuthTokens(*input.settings, host, input);
|
||||
|
||||
auto json = nlohmann::json::parse(
|
||||
readFile(store->toRealPath(downloadFile(store, *input.settings, url, "source", headers).storePath)));
|
||||
auto accessor = store->getFSAccessor();
|
||||
auto downloadResult = downloadFile(store, *input.settings, url, "source", headers);
|
||||
auto json = nlohmann::json::parse(accessor->readFile(CanonPath(downloadResult.storePath.to_string())));
|
||||
|
||||
if (json.is_array() && json.size() >= 1 && json[0]["id"] != nullptr) {
|
||||
return RefInfo{.rev = Hash::parseAny(std::string(json[0]["id"]), HashAlgorithm::SHA1)};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue