aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2023-06-08 22:43:05 +0200
committerLudovic Courtès <ludo@gnu.org>2023-06-08 22:54:58 +0200
commit885d524f79aa4bbfac5dfebf285e1e248184ee70 (patch)
treee48cdf6f498d2c95fad985d58436d4fb19f3e532 /tests
parent3f5e14182931f123c10513a3e1e2abaebfb52279 (diff)
downloadguix-885d524f79aa4bbfac5dfebf285e1e248184ee70.tar
guix-885d524f79aa4bbfac5dfebf285e1e248184ee70.tar.gz
substitute: Gracefully retry after failed partial downloads.
Fixes <https://issues.guix.gnu.org/63443>. Reported by Attila Lendvai <attila@lendvai.name>. * guix/scripts/substitute.scm (catch-system-error): New macro. (download-nar): Add call to 'delete-file-recursively'. * tests/substitute.scm ("substitute, previous partial download around"): New test.
Diffstat (limited to 'tests')
-rw-r--r--tests/substitute.scm25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/substitute.scm b/tests/substitute.scm
index 8df3938b59..7246ed82d5 100644
--- a/tests/substitute.scm
+++ b/tests/substitute.scm
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 Nikita Karetnikov <nikita@karetnikov.org>
-;;; Copyright © 2014-2015, 2017-2019, 2021-2022 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014-2015, 2017-2019, 2021-2023 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -639,6 +639,29 @@ System: mips64el-linux\n")))
(lambda ()
(false-if-exception (delete-file "substitute-retrieved")))))))
+(test-equal "substitute, previous partial download around"
+ "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)))
+ (200 ,(call-with-input-file
+ (string-append %main-substitute-directory
+ "/example.nar")
+ get-bytevector-all)))
+ (dynamic-wind
+ (const #t)
+ (lambda ()
+ (parameterize ((substitute-urls (list (%local-url))))
+ (mkdir-p "substitute-retrieved/a/b/c/d") ;add stale data
+ (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")))))))
+
(test-quit "substitute, narinfo is available but nar is missing"
"failed to find alternative substitute"
(with-narinfo*