summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fussy.asd2
-rw-r--r--fussy.lisp25
2 files changed, 20 insertions, 7 deletions
diff --git a/fussy.asd b/fussy.asd
index 95e3d71..840dd69 100644
--- a/fussy.asd
+++ b/fussy.asd
@@ -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
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