1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-15 06:52:43 +01: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:
Eelco Dolstra 2016-04-15 15:11:34 +02:00
parent 99851c6f06
commit d1b0909894
11 changed files with 52 additions and 28 deletions

View file

@ -20,6 +20,7 @@ void builtinFetchurl(const BasicDerivation & drv)
options.showProgress = DownloadOptions::yes;
auto data = makeDownloader()->download(url->second, options);
assert(data.data);
auto out = drv.env.find("out");
if (out == drv.env.end()) throw Error("attribute url missing");
@ -29,12 +30,12 @@ void builtinFetchurl(const BasicDerivation & drv)
auto unpack = drv.env.find("unpack");
if (unpack != drv.env.end() && unpack->second == "1") {
if (string(data.data, 0, 6) == string("\xfd" "7zXZ\0", 6))
data.data = decompressXZ(data.data);
StringSource source(data.data);
if (string(*data.data, 0, 6) == string("\xfd" "7zXZ\0", 6))
data.data = decompressXZ(*data.data);
StringSource source(*data.data);
restorePath(storePath, source);
} else
writeFile(storePath, data.data);
writeFile(storePath, *data.data);
auto executable = drv.env.find("executable");
if (executable != drv.env.end() && executable->second == "1") {