summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-08-23 18:16:13 +0200
committerLudovic Courtès <ludo@gnu.org>2019-08-23 18:41:49 +0200
commit90c98b5a89038c41a0db0add9e2a3d4d1a1b6102 (patch)
treea770ac6a45d000089267b81be6c6e1ceb8280624
parentb908fcd8c02c26b1e6cdc636b63306a01a21b994 (diff)
downloadguix-90c98b5a89038c41a0db0add9e2a3d4d1a1b6102.tar.gz
swh: 'swh-download' checks return value of 'vault-fetch'.
Reported by Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
in <https://bugs.gnu.org/36931>.

* guix/swh.scm (swh-download): Check whether 'vault-fetch' return false
before calling 'dump-port'.
-rw-r--r--guix/swh.scm31
1 files changed, 17 insertions, 14 deletions
diff --git a/guix/swh.scm b/guix/swh.scm
index df2a138f04..1c416c8dd5 100644
--- a/guix/swh.scm
+++ b/guix/swh.scm
@@ -547,19 +547,22 @@ wait until it becomes available, which could take several minutes."
     ((? revision? revision)
      (call-with-temporary-directory
       (lambda (directory)
-        (let ((input (vault-fetch (revision-directory revision) 'directory))
-              (tar   (open-pipe* OPEN_WRITE "tar" "-C" directory "-xzvf" "-")))
-          (dump-port input tar)
-          (close-port input)
-          (let ((status (close-pipe tar)))
-            (unless (zero? status)
-              (error "tar extraction failure" status)))
-
-          (match (scandir directory)
-            (("." ".." sub-directory)
-             (copy-recursively (string-append directory "/" sub-directory)
-                               output
-                               #:log (%make-void-port "w"))
-             #t))))))
+        (match (vault-fetch (revision-directory revision) 'directory)
+          (#f
+           #f)
+          ((? port? input)
+           (let ((tar (open-pipe* OPEN_WRITE "tar" "-C" directory "-xzvf" "-")))
+             (dump-port input tar)
+             (close-port input)
+             (let ((status (close-pipe tar)))
+               (unless (zero? status)
+                 (error "tar extraction failure" status)))
+
+             (match (scandir directory)
+               (("." ".." sub-directory)
+                (copy-recursively (string-append directory "/" sub-directory)
+                                  output
+                                  #:log (%make-void-port "w"))
+                #t))))))))
     (#f
      #f)))