aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/export-import.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-09-23 22:35:41 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-09-23 22:35:41 +0000
commit45ca7c3e4b92bbafbfa8e30513c9dd3cfe76e3f1 (patch)
tree687ae85bfed1558f05880dfdb8bc358520134c52 /src/libstore/export-import.cc
parente61061c88e0dfcce9329ea9f0b041a35270dfa1a (diff)
parent8d9402f411643c451cf2a0776afcb3a1af0f9a8c (diff)
Merge remote-tracking branch 'upstream/master' into path-info
Diffstat (limited to 'src/libstore/export-import.cc')
-rw-r--r--src/libstore/export-import.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/libstore/export-import.cc b/src/libstore/export-import.cc
index 22ab38233..0640add0e 100644
--- a/src/libstore/export-import.cc
+++ b/src/libstore/export-import.cc
@@ -38,9 +38,9 @@ void Store::exportPath(const StorePath & path, Sink & sink)
filesystem corruption from spreading to other machines.
Don't complain if the stored hash is zero (unknown). */
Hash hash = hashSink.currentHash().first;
- if (hash != info->narHash && info->narHash != Hash(info->narHash->type))
+ if (hash != info->narHash && info->narHash != Hash(info->narHash.type))
throw Error("hash of path '%s' has changed from '%s' to '%s'!",
- printStorePath(path), info->narHash->to_string(Base32, true), hash.to_string(Base32, true));
+ printStorePath(path), info->narHash.to_string(Base32, true), hash.to_string(Base32, true));
teeSink
<< exportMagic
@@ -69,17 +69,18 @@ StorePaths Store::importPaths(Source & source, CheckSigsFlag checkSigs)
if (magic != exportMagic)
throw Error("Nix archive cannot be imported; wrong format");
- ValidPathInfo info(parseStorePath(readString(source)));
+ auto path = parseStorePath(readString(source));
//Activity act(*logger, lvlInfo, format("importing path '%s'") % info.path);
- info.setReferencesPossiblyToSelf(readStorePaths<StorePathSet>(*this, source));
-
+ auto references = readStorePaths<StorePathSet>(*this, source);
auto deriver = readString(source);
+ auto narHash = hashString(htSHA256, *saved.s);
+
+ ValidPathInfo info { path, narHash };
if (deriver != "")
info.deriver = parseStorePath(deriver);
-
- info.narHash = hashString(htSHA256, *saved.s);
+ info.setReferencesPossiblyToSelf(std::move(references));
info.narSize = saved.s->size();
// Ignore optional legacy signature.