me
/
guix
Archived
1
0
Fork 0

swh: Specify 'extid_version' when looking up by external ID.

Reported in <https://gitlab.softwareheritage.org/swh/meta/-/issues/5093>.

* guix/swh.scm (swh-url): Don't add trailing slash when URL contains
parameters.
(lookup-external-id): Specify 'extid_version' to avoid SWH bug from
previous erroneous nar hash computations with the initial SWH deployment
of this feature.

Change-Id: Iea2a5256e0612dae95567907bb11edb92a50df73
Co-authored-by: Ludovic Courtès <ludo@gnu.org>
master
Simon Tournier 2024-06-18 16:02:51 +02:00 committed by Ludovic Courtès
parent 76a2b9d707
commit bd908af0c6
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 14 additions and 5 deletions

View File

@ -165,10 +165,16 @@
(define url
(string-append root (string-join rest "/" 'prefix)))
;; Ensure there's a trailing slash or we get a redirect.
(if (string-suffix? "/" url)
url
(string-append url "/")))
(define (contains-parameters? url)
(match (string-rindex url #\/)
(#f #f)
(offset (string-index (string-drop url (+ 1 offset)) #\?))))
;; Ensure there's a trailing slash or we get a redirect. Don't do that if
;; URL contains parameters.
(cond ((string-suffix? "/" url) url)
((contains-parameters? url) url)
(else (string-append url "/"))))
;; XXX: Work around a bug in Guile 3.0.2 where #:verify-certificate? would
;; be ignored (<https://bugs.gnu.org/40486>).
@ -460,8 +466,11 @@ FALSE-IF-404? is true, return #f upon 404 responses."
"Return the external ID record for ID, a bytevector, of the given TYPE
(currently one of: \"bzr-nodeid\", \"hg-nodeid\", \"nar-sha256\",
\"checksum-sha512\")."
;; Specify "extid_version=1" as explained in
;; <https://gitlab.softwareheritage.org/swh/meta/-/issues/5093>.
(call (swh-url "/api/1/extid" type
(string-append "hex:" (bytevector->base16-string id)))
(string-append "hex:" (bytevector->base16-string id)
"/?extid_version=1"))
json->external-id))
(define* (lookup-directory-by-nar-hash hash #:optional (algorithm 'sha256))