publish: Cache uncompressed nars as well.

Fixes <https://bugs.gnu.org/28664>.
Reported by Maxim Cournoyer <maxim.cournoyer@gmail.com>.

* 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.
master
Ludovic Courtès 2017-10-05 22:15:19 +02:00
parent 7006370e59
commit e5788ebbe1
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 12 additions and 7 deletions

View File

@ -484,9 +484,11 @@ requested using POOL."
#:buffer-size (* 128 1024)) #:buffer-size (* 128 1024))
(rename-file (string-append nar ".tmp") nar)) (rename-file (string-append nar ".tmp") nar))
('none ('none
;; When compression is disabled, we retrieve files directly from the ;; Cache nars even when compression is disabled so that we can
;; store; no need to cache them. ;; guarantee the TTL (see <https://bugs.gnu.org/28664>.)
#t)) (with-atomic-file-output nar
(lambda (port)
(write-file item port)))))
(mkdir-p (dirname narinfo)) (mkdir-p (dirname narinfo))
(with-atomic-file-output narinfo (with-atomic-file-output narinfo
@ -788,8 +790,11 @@ blocking."
;; /nar/<store-item> ;; /nar/<store-item>
((components ... store-item) ((components ... store-item)
(if (nar-path? components) (if (nar-path? components)
(render-nar store request store-item (if cache
#:compression %no-compression) (render-nar/cached store cache request store-item
#:compression %no-compression)
(render-nar store request store-item
#:compression %no-compression))
(not-found request))) (not-found request)))
(x (not-found request))) (x (not-found request)))

View File

@ -340,7 +340,7 @@ FileSize: ~a~%"
200 ;nar/gzip/… 200 ;nar/gzip/…
#t ;Content-Length #t ;Content-Length
#t ;FileSize #t ;FileSize
200) ;nar/… 404) ;nar/…
(call-with-temporary-directory (call-with-temporary-directory
(lambda (cache) (lambda (cache)
(let ((thread (with-separate-output-ports (let ((thread (with-separate-output-ports
@ -393,7 +393,7 @@ FileSize: ~a~%"
(let ((item (add-text-to-store %store "fake-compressed-thing.tar.gz" (let ((item (add-text-to-store %store "fake-compressed-thing.tar.gz"
(random-text)))) (random-text))))
(test-equal "with cache, uncompressed" (test-equal "with cache, uncompressed"
(list #f (list #t
`(("StorePath" . ,item) `(("StorePath" . ,item)
("URL" . ,(string-append "nar/" (basename item))) ("URL" . ,(string-append "nar/" (basename item)))
("Compression" . "none")) ("Compression" . "none"))