From 29887c80c33b9f909151b465cb99160160cc96c3 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Date: Tue, 12 Apr 2022 14:36:22 +0800 Subject: [PATCH] code: ensure download archive if failed --- lisp/_prepare.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lisp/_prepare.el b/lisp/_prepare.el index c59fcdae..fe99d0e8 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -100,6 +100,28 @@ the `eask-start' execution.") (mapc (lambda (elm) (setq result (max result (length (format "%s" elm))))) sequence) result)) +;; +;;; Archive + +(defun eask--download-archives () + "If archives download failed; download it manually." + (dolist (archive package-archives) + (let* ((location (cdr archive)) + (name (car archive)) + (file "archive-contents") + (dir (expand-file-name (concat "archives/" name) package-user-dir)) + (local-file (expand-file-name file dir)) + (url (url-expand-file-name file location)) + (local-archive-p (string= name "local"))) + (unless (file-exists-p local-file) + (eask-with-progress + (format "Downloading archive `%s' manually... " (ansi-yellow name)) + (unless local-archive-p + (url-copy-file url local-file t)) + (if local-archive-p "skipped ✗" "done ✓")))))) + +(add-hook 'package--post-download-archives-hook #'eask--download-archives) + ;; ;;; Package