summaryrefslogtreecommitdiff
path: root/fussy.lisp
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-11-18 09:05:46 -0800
committercolin <colin@cicadas.surf>2023-11-18 09:05:46 -0800
commit06f1c5825254a6806ac34fa8b2797fceaca6c7c9 (patch)
tree4fa4c27b328005b30e3e864f62784fa3c46238fb /fussy.lisp
parent8ee6c3a1854dc950d1294449a7af6995fd4770be (diff)
Fix: handle dns errors
Diffstat (limited to 'fussy.lisp')
-rw-r--r--fussy.lisp25
1 files changed, 19 insertions, 6 deletions
diff --git a/fussy.lisp b/fussy.lisp
index 7b6d706..2df651e 100644
--- a/fussy.lisp
+++ b/fussy.lisp
@@ -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