From 49e272f6472360ba952aa4fa62cc8e61a1b4d6b7 Mon Sep 17 00:00:00 2001 From: Falco Peijnenburg Date: Sat, 27 Oct 2018 18:12:02 +0200 Subject: copyStorePath: Fix hash errors when copying from older store This commit partially reverts 48662d151bdf4a38670897beacea9d1bd750376a. When copying from an older store (in my case a store running Nix 1.11.7), nix would throw errors about there being no hash. This is fixed by recalculating the hash. --- src/libstore/store-api.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 92e2685f7f66..dc54c735fdb1 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -588,15 +588,19 @@ void copyStorePath(ref srcStore, ref dstStore, uint64_t total = 0; - // FIXME -#if 0 if (!info->narHash) { + StringSink sink; + srcStore->narFromPath({storePath}, sink); auto info2 = make_ref(*info); info2->narHash = hashString(htSHA256, *sink.s); if (!info->narSize) info2->narSize = sink.s->size(); + if (info->ultimate) info2->ultimate = false; info = info2; + + StringSource source(*sink.s); + dstStore->addToStore(*info, source, repair, checkSigs); + return; } -#endif if (info->ultimate) { auto info2 = make_ref(*info); -- cgit 1.4.1