doom-refresh-packages: caches refresh time in file

This commit is contained in:
Henrik Lissner 2017-02-11 06:00:27 -05:00
parent 07b38ac36c
commit 25962a6beb

View file

@ -8,10 +8,15 @@
(defun doom-refresh-packages () (defun doom-refresh-packages ()
"Refresh ELPA packages." "Refresh ELPA packages."
(doom-initialize) (doom-initialize)
(when (or (not doom-packages-last-refresh) (let ((refresh-cache (f-expand "last-pkg-refresh" doom-cache-dir)))
(> (nth 1 (time-since doom-packages-last-refresh)) 3600)) (when (and (not doom-packages-last-refresh)
(package-refresh-contents) (f-exists-p refresh-cache))
(setq doom-packages-last-refresh (current-time)))) (setq doom-packages-last-refresh (read (f-read refresh-cache))))
(when (or (not doom-packages-last-refresh)
(> (nth 1 (time-since doom-packages-last-refresh)) 600))
(package-refresh-contents)
(setq doom-packages-last-refresh (current-time))
(f-write (pp-to-string doom-packages-last-refresh) 'utf-8 refresh-cache))))
;;;###autoload ;;;###autoload
(defun doom-package-backend (name) (defun doom-package-backend (name)