guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/12: import: launchpad: Gracefully handle 404s from api.launchpad.net.


From: guix-commits
Subject: 01/12: import: launchpad: Gracefully handle 404s from api.launchpad.net.
Date: Fri, 18 Jun 2021 08:25:49 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit f371972e788df6310e12d15914d70d834c9deadb
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Jun 15 23:18:46 2021 +0200

    import: launchpad: Gracefully handle 404s from api.launchpad.net.
    
    Fixes <https://bugs.gnu.org/49031>.
    Reported by Emad Alblueshi <emad.albloushi@gmail.com>.
    
    * guix/import/launchpad.scm (latest-released-version): Gracefully handle
    'json-fetch' returning #f.
---
 guix/import/launchpad.scm | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/guix/import/launchpad.scm b/guix/import/launchpad.scm
index fd3cfa8..a52b39a 100644
--- a/guix/import/launchpad.scm
+++ b/guix/import/launchpad.scm
@@ -110,15 +110,14 @@ for example, 'linuxdcpp'. Return #f if there is no 
releases."
                                        char-set:digit)
                        (assoc-ref x "version"))))
 
-  (assoc-ref
-   (last (remove
-          pre-release?
-          (vector->list
-           (assoc-ref (json-fetch
-                       (string-append "https://api.launchpad.net/1.0/";
-                                      package-name "/releases"))
-                      "entries"))))
-   "version"))
+  (match (json-fetch
+          (string-append "https://api.launchpad.net/1.0/";
+                         package-name "/releases"))
+    (#f #f)                                       ;404 or similar
+    (json
+     (assoc-ref
+      (last (remove pre-release? (vector->list (assoc-ref json "entries"))))
+      "version"))))
 
 (define (latest-release pkg)
   "Return an <upstream-source> for the latest release of PKG."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]