diff options
-rw-r--r-- | fussy.asd | 2 | ||||
-rw-r--r-- | fussy.lisp | 25 |
2 files changed, 20 insertions, 7 deletions
@@ -4,7 +4,7 @@ :description "An Emacs themes gallery" :author "Colin <colin@cicadas.surf>" :license "AGPLv3" - :version "0.0.1" + :version "1.0.1" :serial t :depends-on (#:hyperquirks #:bknr.datastore @@ -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 |