Skip to content

Commit

Permalink
code: ensure download archive if failed
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Apr 12, 2022
1 parent 7e280df commit 29887c8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lisp/_prepare.el
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 29887c8

Please sign in to comment.