Add --threads option to 'doom update' #1736
This commit is contained in:
parent
3e3808aa8d
commit
84837fa0d6
1 changed files with 12 additions and 3 deletions
|
@ -19,11 +19,17 @@ This works by fetching all installed package repos and checking the distance
|
|||
between HEAD and FETCH_HEAD. This can take a while.
|
||||
|
||||
This excludes packages whose `package!' declaration contains a non-nil :freeze
|
||||
or :ignore property."
|
||||
or :ignore property.
|
||||
|
||||
Switches:
|
||||
-t/--timeout TTL Seconds until a thread is timed out (default: 45)
|
||||
--threads N How many threads to use (default: 8)"
|
||||
(doom--ensure-autoloads-while
|
||||
(straight-check-all)
|
||||
(doom-packages-update
|
||||
doom-auto-accept
|
||||
(when-let (threads (cadr (member "--threads" args)))
|
||||
(string-to-number threads))
|
||||
(when-let (timeout (cadr (or (member "--timeout" args)
|
||||
(member "-t" args))))
|
||||
(string-to-number timeout)))))
|
||||
|
@ -213,7 +219,7 @@ a list of packages that will be installed."
|
|||
(cons 'error e))))))
|
||||
|
||||
|
||||
(defun doom-packages-update (&optional auto-accept-p timeout)
|
||||
(defun doom-packages-update (&optional auto-accept-p threads timeout)
|
||||
"Updates packages.
|
||||
|
||||
Unless AUTO-ACCEPT-P is non-nil, this function will prompt for confirmation with
|
||||
|
@ -222,14 +228,17 @@ a list of packages that will be updated."
|
|||
(print-group!
|
||||
(when timeout
|
||||
(print! (info "Using %S as timeout value" timeout)))
|
||||
(when threads
|
||||
(print! (info "Limiting to %d thread(s)" threads)))
|
||||
;; REVIEW Does this fail gracefully enough? Is it error tolerant?
|
||||
;; TODO Add version-lock checks; don't want to spend all this effort on
|
||||
;; packages that shouldn't be updated
|
||||
(let* ((futures
|
||||
;; REVIEW We can do better "thread" management here
|
||||
(or (cl-loop for group
|
||||
in (seq-partition (hash-table-values straight--repo-cache)
|
||||
(/ (hash-table-count straight--repo-cache)
|
||||
16))
|
||||
(or threads 8)))
|
||||
for future = (doom--packages-remove-outdated-f group)
|
||||
if (processp future)
|
||||
collect (cons future group)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue