From 133910fd65363eb1fb26aeabb48fa07434ee83c5 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Tue, 14 Oct 2025 16:59:31 +0200 Subject: [PATCH] inferior: cached-channel-instance: Recalculate key after fetching channels. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #3454. Because the channels in the incoming argument do not have to include all dependencies, it is possible a cache entry with wrong key is created. Recalculate the key after obtaining all dependencies of channels through latest-channel-instances. * guix/inferior.scm (cached-channel-instance): Recalculate cached file location from latest-channel-instances commits before caching. Change-Id: I37da107520bf5abd89c92a5ce6d3e2fc399454c3 Signed-off-by: Ludovic Courtès --- guix/inferior.scm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/guix/inferior.scm b/guix/inferior.scm index 1440c684ccdf7876f3b2b6fba1e14b29871eddca..f23d35c9babbda4d68f2abe40fdacdfaf976c71f 100644 --- a/guix/inferior.scm +++ b/guix/inferior.scm @@ -915,13 +915,13 @@ X.509 host certificate; otherwise, warn about the problem and keep going." #:verify-certificate? verify-certificate?)) channels)) - (define key + (define (key commits) (bytevector->base32-string (sha256 (string->utf8 (string-concatenate commits))))) - (define cached - (string-append cache-directory "/" key)) + (define (cached commits) + (string-append cache-directory "/" (key commits))) (define (base32-encoded-sha256? str) (= (string-length str) 52)) @@ -962,8 +962,8 @@ X.509 host certificate; otherwise, warn about the problem and keep going." (file-expiration-time ttl)) - (if (file-exists? cached) - cached + (if (file-exists? (cached commits)) + (cached commits) (run-with-store store (mlet* %store-monad ((instances -> (latest-channel-instances store channels @@ -975,6 +975,7 @@ X.509 host certificate; otherwise, warn about the problem and keep going." validate-channels #:verify-certificate? verify-certificate?)) + (commits -> (map channel-instance-commit instances)) (profile (channel-instances->derivation instances))) (mbegin %store-monad @@ -985,9 +986,9 @@ X.509 host certificate; otherwise, warn about the problem and keep going." ;; Cache if and only if AUTHENTICATE? is true. (if authenticate? (mbegin %store-monad - (symlink* (derivation->output-path profile) cached) - (add-indirect-root* cached) - (return cached)) + (symlink* (derivation->output-path profile) (cached commits)) + (add-indirect-root* (cached commits)) + (return (cached commits))) (mbegin %store-monad (add-temp-root* (derivation->output-path profile)) (return (derivation->output-path profile)))))))))