mirror of
https://github.com/NixOS/nix
synced 2025-06-25 19:01:16 +02:00
BinaryCacheStore::readFile(): Return a shared_ptr to a string
This allows readFile() to indicate that a file doesn't exist, and might eliminate some large string copying.
This commit is contained in:
parent
99851c6f06
commit
d1b0909894
11 changed files with 52 additions and 28 deletions
|
@ -58,12 +58,18 @@ protected:
|
|||
throw Error("uploading to an HTTP binary cache is not supported");
|
||||
}
|
||||
|
||||
std::string getFile(const std::string & path) override
|
||||
std::shared_ptr<std::string> getFile(const std::string & path) override
|
||||
{
|
||||
auto downloader(downloaders.get());
|
||||
DownloadOptions options;
|
||||
options.showProgress = DownloadOptions::no;
|
||||
return downloader->download(cacheUri + "/" + path, options).data;
|
||||
try {
|
||||
return downloader->download(cacheUri + "/" + path, options).data;
|
||||
} catch (DownloadError & e) {
|
||||
if (e.error == Downloader::NotFound || e.error == Downloader::Forbidden)
|
||||
return 0;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue