offload: Gracefully handle invalid results from 'machines.scm'.
authorLudovic Courtès <ludo@gnu.org>
Thu, 14 Jun 2018 21:08:08 +0000 (23:08 +0200)
committerLudovic Courtès <ludo@gnu.org>
Thu, 14 Jun 2018 21:34:59 +0000 (23:34 +0200)
* guix/scripts/offload.scm (build-machines): Check the result of FILE.
Ignore it if it's not a list of <build-machine>.

guix/scripts/offload.scm

index fb61d7c..664497b 100644 (file)
@@ -124,7 +124,15 @@ determined."
       (save-module-excursion
        (lambda ()
          (set-current-module %user-module)
-         (primitive-load file))))
+         (match (primitive-load file)
+           (((? build-machine? machines) ...)
+            machines)
+           (_
+            ;; Instead of crashing, assume the empty list.
+            (warning (G_ "'~a' did not return a list of build machines; \
+ignoring it~%")
+                     file)
+            '())))))
     (lambda args
       (match args
         (('system-error . rest)