1
0
Fork 0
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:
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

@ -162,7 +162,7 @@ int main(int argc, char * * argv)
AutoDelete tmpDir(createTempDir(), true);
Path tmpFile = (Path) tmpDir + "/tmp";
writeFile(tmpFile, result.data);
writeFile(tmpFile, *result.data);
/* Optionally unpack the file. */
if (unpack) {
@ -186,7 +186,7 @@ int main(int argc, char * * argv)
/* FIXME: inefficient; addToStore() will also hash
this. */
hash = unpack ? hashPath(ht, tmpFile).first : hashString(ht, result.data);
hash = unpack ? hashPath(ht, tmpFile).first : hashString(ht, *result.data);
if (expectedHash != Hash(ht) && expectedHash != hash)
throw Error(format("hash mismatch for %1%") % uri);