aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tournier <zimon.toutoune@gmail.com>2024-06-18 16:02:51 +0200
committerLudovic Courtès <ludo@gnu.org>2024-06-26 23:56:56 +0200
commitbd908af0c619cb1b74afeeb07839d7af08de9d91 (patch)
tree030a344daf5c2880da24ce0709cb0f9e7d09b6e5
parent76a2b9d70778918f4cfd0c07592d82fd176b3603 (diff)
downloadguix-bd908af0c619cb1b74afeeb07839d7af08de9d91.tar.gz
guix-bd908af0c619cb1b74afeeb07839d7af08de9d91.zip
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>
-rw-r--r--guix/swh.scm19
1 files changed, 14 insertions, 5 deletions
diff --git a/guix/swh.scm b/guix/swh.scm
index f602cd89d1..fd17b04b75 100644
--- a/guix/swh.scm
+++ b/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))