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
parent
76a2b9d707
commit
bd908af0c6
19
guix/swh.scm
19
guix/swh.scm
|
@ -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))
|
||||
|
|
Reference in New Issue