summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix/nar.scm3
-rw-r--r--tests/nar.scm7
2 files changed, 9 insertions, 1 deletions
diff --git a/guix/nar.scm b/guix/nar.scm
index 4bc2deb229..89a71302e0 100644
--- a/guix/nar.scm
+++ b/guix/nar.scm
@@ -112,7 +112,8 @@
(write-long-long size p)
(call-with-binary-input-file file
;; Use `sendfile' when available (Guile 2.0.8+).
- (if (compile-time-value (defined? 'sendfile))
+ (if (and (compile-time-value (defined? 'sendfile))
+ (file-port? p))
(cut sendfile p <> size 0)
(cut dump <> p size)))
(write-padding size p))
diff --git a/tests/nar.scm b/tests/nar.scm
index 9f21f990c8..7ae8cf0aa7 100644
--- a/tests/nar.scm
+++ b/tests/nar.scm
@@ -183,6 +183,13 @@
(test-begin "nar")
+(test-assert "write-file supports non-file output ports"
+ (let ((input (string-append (dirname (search-path %load-path "guix.scm"))
+ "/guix"))
+ (output (%make-void-port "w")))
+ (write-file input output)
+ #t))
+
(test-assert "write-file + restore-file"
(let* ((input (string-append (dirname (search-path %load-path "guix.scm"))
"/guix"))