Fix wrong-type-arg: listp error on 'doom update'

Caused when async fails to create a child process for a certain group of
packages (needs to be investigated more).
This commit is contained in:
Henrik Lissner 2019-08-07 21:07:43 -04:00
parent f42bfde8ae
commit ef60762a92
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -199,42 +199,57 @@ a list of packages that will be updated."
;; REVIEW Does this fail gracefully enough? Is it error tolerant? ;; REVIEW Does this fail gracefully enough? Is it error tolerant?
;; TODO Add version-lock checks; don't want to spend all this effort on ;; TODO Add version-lock checks; don't want to spend all this effort on
;; packages that shouldn't be updated ;; packages that shouldn't be updated
(let ((futures (let* ((futures
(or (cl-loop for group (or (cl-loop for group
in (seq-partition (hash-table-values straight--repo-cache) in (seq-partition (hash-table-values straight--repo-cache)
8) (/ (hash-table-count straight--repo-cache)
if (doom--packages-remove-outdated-f group) 8))
collect it) for future = (doom--packages-remove-outdated-f group)
(error! "Failed to create any threads")))) if (processp future)
collect (cons future group)
else
do (print! (warn "Failed to create thread for:\n\n%s\n\nReason: %s"
group future)))
(error! "Failed to create any threads")))
(total (length futures))
(timeout 20))
(condition-case-unless-debug e (condition-case-unless-debug e
(let ((total (length futures)) (let (specs)
specs)
(while futures (while futures
(print! ". %.0f%%" (* (/ (- total (length futures)) (print! ". %.0f%%" (* (/ (- total (length futures))
(float total)) (float total))
100)) 100))
(while (not (async-ready (car futures))) (let ((time 0))
(sleep-for 2) (catch 'timeout
(print! ".")) (while (not (async-ready (caar futures)))
(cl-destructuring-bind (status . result) (when (> time timeout)
(or (async-get (pop futures)) (print! (warn "A thread has timed out. The following packages were skipped:\n\n %s"
(cons nil nil)) (string-join (cdar futures) ", ")))
(cond ((null status) (throw 'timeout t))
(error "Thread returned an invalid result: %S" errors result)) (sleep-for 2)
((eq status 'error) (cl-incf time)
(error "There were errors:\n\n%s" (print! "."))
(if (and (listp result) (cl-destructuring-bind (status . result)
(symbolp (car result))) (or (async-get (car (pop futures)))
(prin1-to-string result) (cons nil nil))
(mapconcat (lambda (e) (cond ((null status)
(format! " - %s: %s" (yellow (car e)) (cdr e))) (error "Thread returned an invalid result: %S" errors))
result ((eq status 'error)
"\n")))) (error "There were errors:\n\n%s"
((eq status 'ok) (cond ((and (listp result)
(print! (debug "Appended %S to package list") (or result "nothing")) (symbolp (car result)))
(appendq! specs result)) (prin1-to-string result))
((error "Thread returned a non-standard status: %s\n\n%s" ((stringp result)
status result))))) result)
((mapconcat (lambda (e)
(format! " - %s: %s" (yellow (car e)) (cdr e)))
result
"\n")))))
((eq status 'ok)
(print! (debug "Appended %S to package list") (or result "nothing"))
(appendq! specs result))
((error "Thread returned a non-standard status: %s\n\n%s"
status result)))))))
(print! ". 100%%") (print! ". 100%%")
(terpri) (terpri)
(if-let (specs (delq nil specs)) (if-let (specs (delq nil specs))