From 101d9f3fd43b436d5dc7ef13e644c7fbbc7f62d5 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 15 May 2013 23:40:09 +0200 Subject: substitute-binary: Pass `filtered-port' an unbuffered port. This fixes a bug whereby `read-response' would read more than just the response, with the extra data going into the port's buffer; the "bzip2 -dc" process spawned by `filtered-port' would not see the those buffered data, which are definitely lost, and would bail out with "bzip2: (stdin) is not a bzip2 file." * guix/utils.scm (filtered-port): Document that INPUT must be unbuffered. * guix/web.scm (http-fetch): Add `buffered?' parameter. Call `open-socket-for-uri' explicitly, and call `setvbuf' when BUFFERED? is false. Pass the port to `http-get'. Close it upon 301/302. * guix/scripts/substitute-binary.scm (fetch): Add `buffered?' parameter. Pass it to `http-fetch'; honor it for `file' URIs. (guix-substitute-binary): Call `fetch' with #:buffered? #f for port RAW. * tests/utils.scm ("filtered-port, file"): Open FILE as unbuffered. --- tests/utils.scm | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'tests/utils.scm') diff --git a/tests/utils.scm b/tests/utils.scm index c2fb274193..e8549204d0 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -102,17 +102,16 @@ list)) (test-assert "filtered-port, file" - (let ((file (search-path %load-path "guix.scm"))) - (call-with-input-file file - (lambda (input) - (let*-values (((compressed pids1) - (filtered-port `(,%gzip "-c" "--fast") input)) - ((decompressed pids2) - (filtered-port `(,%gzip "-d") compressed))) - (and (every (compose zero? cdr waitpid) - (append pids1 pids2)) - (equal? (get-bytevector-all decompressed) - (call-with-input-file file get-bytevector-all)))))))) + (let* ((file (search-path %load-path "guix.scm")) + (input (open-file file "r0"))) + (let*-values (((compressed pids1) + (filtered-port `(,%gzip "-c" "--fast") input)) + ((decompressed pids2) + (filtered-port `(,%gzip "-d") compressed))) + (and (every (compose zero? cdr waitpid) + (append pids1 pids2)) + (equal? (get-bytevector-all decompressed) + (call-with-input-file file get-bytevector-all)))))) (test-assert "filtered-port, non-file" (let ((data (call-with-input-file (search-path %load-path "guix.scm") -- cgit v1.2.3