guix-patches
[Top][All Lists]
Advanced

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

[bug#58017] [PATCH 2/2] substitute: Retry downloading when a nar is unav


From: Maxime Devos
Subject: [bug#58017] [PATCH 2/2] substitute: Retry downloading when a nar is unavailable.
Date: Sat, 24 Sep 2022 03:57:33 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0

+(test-equal "substitute, first URL has narinfo but nar is 404, both URLs 
authorized"
+  "Substitutable data."
+  (with-narinfo*
+      (string-append %narinfo "Signature: "
+                     (signature-field %narinfo))
+      %main-substitute-directory
+
+    (with-http-server `((200 ,(string-append %narinfo "Signature: "
+                                             (signature-field %narinfo)))
+                        (404 "Sorry, nar is missing!"))
+      (dynamic-wind
+        (const #t)
+        (lambda ()
+          (parameterize ((substitute-urls
+                          (list (%local-url)
+                                (string-append "file://"
+                                               %main-substitute-directory))))
+            (request-substitution (string-append (%store-prefix)
+                                                 
"/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
+                                  "substitute-retrieved"))
+          (call-with-input-file "substitute-retrieved" get-string-all))
+        (lambda ()
+          (false-if-exception (delete-file "substitute-retrieved")))))))

Shouldn't it only ignore 'file not found' (ENOENT?) exceptions?
If the exception handling is refined a bit, it becomes a bit more complicated, and could be simplified to (when [exists] [delete]), as there are no atomicity concerns.

This test, and some others, can be improved by also checking the URI. While currently 'with-http-server' does not support that, there are (5 months, with the v1 having seen some reviewing and a v2 available) patches for that at <https://issues.guix.gnu.org/53389>.

That patch also _requires_ always mentioning the URI, if the cover letter is correct. It also allows simplifying the use of '%local-url' a bit.

Greetings,
Maxime.

Attachment: OpenPGP_0x49E3EE22191725EE.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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