diff options
Diffstat (limited to 'fussy.lisp')
-rw-r--r-- | fussy.lisp | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -4,6 +4,9 @@ (defvar +default-emacs-package-archive+ "https://melpa.org/packages/archive-contents") +(defparameter +retry-wait+ 60 + "Nubmer of seconds to wait between http request retries.") + (defun emacs-reader-readtable () "Return a readtable that will read the emacs package archive contents." @@ -15,15 +18,25 @@ contents." (set-macro-character #\] (get-macro-character #\) nil)) *readtable*))) -(defun fetch-emacs-archive (&optional (archive +default-emacs-package-archive+)) +(defun fetch-emacs-archive + (&optional + (archive +default-emacs-package-archive+) + (retries 10)) "Fetch the package archive from ARCHIVE, a url, and read it in using the emacs' reader readtable." ;; TODO: HANDLE HTTP ERRORS, HANDLE TIMEOUT, HANDLE READ ERRORS - (multiple-value-bind (stream status) (dexador:get archive :want-stream t) - (when (= 200 status) - (let* ((*package* (find-package :fussy)) - (*readtable* (emacs-reader-readtable))) - (read stream))))) + (when (plusp retries) + (handler-case + (multiple-value-bind (stream status) (dexador:get archive :want-stream t) + (when (= 200 status) + (let* ((*package* (find-package :fussy)) + (*readtable* (emacs-reader-readtable))) + (read stream)))) + (usocket:ns-host-not-found-error () + (fussy-log "Host Not Found: ~a~%Retrying in ~a seconds...~%" + archive +retry-wait+) + (sleep +retry-wait+) + (fetch-emacs-archive archive (1- retries)))))) (defclass/std theme-pkg (db:store-object) ((name |