guix_mirror_bot pushed a commit to branch master
in repository guix.

commit 133910fd65363eb1fb26aeabb48fa07434ee83c5
Author: Rutherther <[email protected]>
AuthorDate: Tue Oct 14 16:59:31 2025 +0200

    inferior: cached-channel-instance: Recalculate key after fetching channels.
    
    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 <[email protected]>
---
 guix/inferior.scm | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/guix/inferior.scm b/guix/inferior.scm
index 1440c684cc..f23d35c9ba 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)))))))))

Reply via email to