guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/01: publish: Cache uncompressed nars as well.


From: Ludovic Courtès
Subject: 01/01: publish: Cache uncompressed nars as well.
Date: Thu, 5 Oct 2017 17:05:11 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit e5788ebbe1f45a1088249b9138de17b330609712
Author: Ludovic Courtès <address@hidden>
Date:   Thu Oct 5 22:15:19 2017 +0200

    publish: Cache uncompressed nars as well.
    
    Fixes <https://bugs.gnu.org/28664>.
    Reported by Maxim Cournoyer <address@hidden>.
    
    * guix/scripts/publish.scm (bake-narinfo+nar): When COMPRESSION is
    'none, write NAR instead of doing nothing.
    (make-request-handler): Use 'render-nar/cached' for /nar URLs with no
    compression.
    * tests/publish.scm ("with cache", "with cache, uncompressed"): Adjust
    expected result accordingly.
---
 guix/scripts/publish.scm | 15 ++++++++++-----
 tests/publish.scm        |  4 ++--
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index ade3c49..dd54f03 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -484,9 +484,11 @@ requested using POOL."
          #:buffer-size (* 128 1024))
        (rename-file (string-append nar ".tmp") nar))
       ('none
-       ;; When compression is disabled, we retrieve files directly from the
-       ;; store; no need to cache them.
-       #t))
+       ;; Cache nars even when compression is disabled so that we can
+       ;; guarantee the TTL (see <https://bugs.gnu.org/28664>.)
+       (with-atomic-file-output nar
+         (lambda (port)
+           (write-file item port)))))
 
     (mkdir-p (dirname narinfo))
     (with-atomic-file-output narinfo
@@ -788,8 +790,11 @@ blocking."
           ;; /nar/<store-item>
           ((components ... store-item)
            (if (nar-path? components)
-               (render-nar store request store-item
-                           #:compression %no-compression)
+               (if cache
+                   (render-nar/cached store cache request store-item
+                                      #:compression %no-compression)
+                   (render-nar store request store-item
+                               #:compression %no-compression))
                (not-found request)))
 
           (x (not-found request)))
diff --git a/tests/publish.scm b/tests/publish.scm
index 31043f7..f33898f 100644
--- a/tests/publish.scm
+++ b/tests/publish.scm
@@ -340,7 +340,7 @@ FileSize: ~a~%"
         200                                       ;nar/gzip/…
         #t                                        ;Content-Length
         #t                                        ;FileSize
-        200)                                      ;nar/…
+        404)                                      ;nar/…
   (call-with-temporary-directory
    (lambda (cache)
      (let ((thread (with-separate-output-ports
@@ -393,7 +393,7 @@ FileSize: ~a~%"
 (let ((item (add-text-to-store %store "fake-compressed-thing.tar.gz"
                                (random-text))))
   (test-equal "with cache, uncompressed"
-    (list #f
+    (list #t
           `(("StorePath" . ,item)
             ("URL" . ,(string-append "nar/" (basename item)))
             ("Compression" . "none"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]