From 299d0b7f9a421f7ae23e42114f37e9d1776a32f3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 3 May 2024 17:12:54 +0200 Subject: [PATCH] TarballInputScheme: Fix fetchToStore() caching --- src/libfetchers/fetchers.cc | 4 +++- src/libfetchers/tarball.cc | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libfetchers/fetchers.cc b/src/libfetchers/fetchers.cc index b025d9aef5c..7f2edbf6667 100644 --- a/src/libfetchers/fetchers.cc +++ b/src/libfetchers/fetchers.cc @@ -248,7 +248,9 @@ std::pair, Input> Input::getAccessorUnchecked(ref stor auto [accessor, final] = scheme->getAccessor(store, *this); - accessor->fingerprint = scheme->getFingerprint(store, final); + if (!accessor->fingerprint) + // FIXME: remove getFingerprint()? + accessor->fingerprint = scheme->getFingerprint(store, final); return {accessor, std::move(final)}; } diff --git a/src/libfetchers/tarball.cc b/src/libfetchers/tarball.cc index a1f934c35df..dd35904ae77 100644 --- a/src/libfetchers/tarball.cc +++ b/src/libfetchers/tarball.cc @@ -352,8 +352,11 @@ struct TarballInputScheme : CurlInputScheme if (result.lastModified && !input.attrs.contains("lastModified")) input.attrs.insert_or_assign("lastModified", uint64_t(result.lastModified)); - input.attrs.insert_or_assign("narHash", - getTarballCache()->treeHashToNarHash(result.treeHash).to_string(HashFormat::SRI, true)); + auto narHash = getTarballCache()->treeHashToNarHash(result.treeHash).to_string(HashFormat::SRI, true); + + input.attrs.insert_or_assign("narHash", narHash); + + result.accessor->fingerprint = narHash; return {result.accessor, input}; }