[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hyperdrive 737c60da80 5/6: Fix: (h/install) Handle missing
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hyperdrive 737c60da80 5/6: Fix: (h/install) Handle missing curl program |
Date: |
Fri, 9 Aug 2024 19:00:08 -0400 (EDT) |
branch: elpa/hyperdrive
commit 737c60da8012ad401bcd145b6942854c3c0520a1
Author: Joseph Turner <joseph@ushin.org>
Commit: Joseph Turner <joseph@ushin.org>
Fix: (h/install) Handle missing curl program
Previously, when `curl' executable program was missing, the command
errored nearly instantly with
hyperdrive error: "Downloading failed; no more mirrors available"
Now, the file-missing error is handled specially.
Also, refactor labeled functions to make `try' more high-level.
---
hyperdrive.el | 53 ++++++++++++++++++++++++++---------------------------
1 file changed, 26 insertions(+), 27 deletions(-)
diff --git a/hyperdrive.el b/hyperdrive.el
index b164730c2e..af8bf79dea 100644
--- a/hyperdrive.el
+++ b/hyperdrive.el
@@ -1421,34 +1421,33 @@ If FORCEP, don't prompt for confirmation before
downloading."
monitor-buffer size)
(cl-labels
((try ()
+ (unless urls-and-hashes
+ (setf h/install-process nil)
+ (h/menu-refresh)
+ (h/error "Downloading failed; no more mirrors available"))
(pcase-let (((map :url :sha256) (pop urls-and-hashes)))
- (unless size
- ;; Only successfully get size once.
- (ignore-errors
- (h/message "Checking server %S..."
- (url-host (url-generic-parse-url url)))
- (setf size (head-size url))))
- (if size
- (if (or forcep
- (yes-or-no-p
- (format "Download and install gateway (%s)? "
- (file-size-human-readable size))))
- (progn
- (setf forcep t) ;; Don't prompt again.
- (download url sha256))
- (h/message "Installation canceled."))
- ;; HEAD request failed: try next URL.
- (h/message "Server %S unresponsive. Trying next server..."
- (url-host (url-generic-parse-url url)))
- (if urls-and-hashes
- (try)
- (setf h/install-process nil)
- (h/menu-refresh)
- (hyperdrive-error "Downloading failed; no more mirrors
available")))))
- (head-size (url)
- (when-let ((response (plz 'head url :as 'response :connect-timeout
5)))
- (cl-parse-integer
- (alist-get 'content-length (plz-response-headers response)))))
+ (when (or size (ensure-size url))
+ (if (or forcep (yes-or-no-p
+ (format "Download and install gateway (%s)? "
+ (file-size-human-readable size))))
+ (progn
+ (setf forcep t) ;; Don't prompt again.
+ (download url sha256))
+ (h/message "Installation canceled.")))))
+ (ensure-size (url)
+ (let ((host (url-host (url-generic-parse-url url))))
+ (h/message "Checking server %S..." host)
+ (condition-case err
+ (pcase-let (((cl-struct plz-response
+ (headers (map content-length)))
+ (plz 'head url :as 'response :connect-timeout
5)))
+ (setf size (cl-parse-integer content-length)))
+ ;; Likely missing `curl' executable: Signal error.
+ (file-missing (h/error "Please install `curl' program."))
+ ;; Any other error: Try next URL.
+ (t (h/message "%S unresponsive. Trying next server..." host)
+ (try)
+ nil))))
(download (url sha256)
(let* ((temp-file (make-temp-name
(expand-file-name "hyperdrive-gateway-"
- [nongnu] elpa/hyperdrive updated (69d5b8aef9 -> d98780cfab), ELPA Syncer, 2024/08/09
- [nongnu] elpa/hyperdrive 70220505c7 1/6: Tidy: (CHANGELOG.org) Markup, ELPA Syncer, 2024/08/09
- [nongnu] elpa/hyperdrive d98780cfab 6/6: Docs: Document curl dependency, ELPA Syncer, 2024/08/09
- [nongnu] elpa/hyperdrive a38d0c8753 3/6: Change: (h/handler-default, h/write-buffer) Say when drive not safe, ELPA Syncer, 2024/08/09
- [nongnu] elpa/hyperdrive 737c60da80 5/6: Fix: (h/install) Handle missing curl program,
ELPA Syncer <=
- [nongnu] elpa/hyperdrive b6cc722d22 2/6: Change: (hyperdrive-describe) Show safep in describe buffer, ELPA Syncer, 2024/08/09
- [nongnu] elpa/hyperdrive 4544ade923 4/6: Fix: (h/gateway-urls-and-hashes) Correct SourceHut build URLs, ELPA Syncer, 2024/08/09