diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-04-15T13·11+0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-04-15T13·39+0200 |
commit | d1b0909894a302540f979d904dd378af1cad620c (patch) | |
tree | 691ec2d838e4449897549a537145971d9b12a3d5 /src/libstore/builtins.cc | |
parent | 99851c6f06c80fe2222c5e5fcef963804e907170 (diff) |
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.
Diffstat (limited to 'src/libstore/builtins.cc')
-rw-r--r-- | src/libstore/builtins.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libstore/builtins.cc b/src/libstore/builtins.cc index c22c44f3c7e3..50417b644a02 100644 --- a/src/libstore/builtins.cc +++ b/src/libstore/builtins.cc @@ -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") { |