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.
This commit is contained in:
Ludovic Courtès 2021-06-15 23:18:46 +02:00
parent bccf2a9e25
commit f371972e78
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -110,15 +110,14 @@ (define (pre-release? x)
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."