config/cron/job: Fix load when currency.units has not been created yet

master
Pierre Neidhardt 2019-01-21 10:14:34 +01:00
parent 8152c884ba
commit 0cd8a1acac
1 changed files with 4 additions and 2 deletions

View File

@ -1,4 +1,4 @@
;; -*- mode: Lisp; -*-
;; -*- mode: scheme; -*-
;; This cannot be let-bound within `job'.
(define currency-file (string-append (getenv "HOME") "/.cache/currency.units"))
@ -6,7 +6,9 @@
(job
(lambda (current-time)
(let* ((seconds-in-a-day (* 60 60 24))
(currency-time (stat:mtime (stat currency-file))))
(currency-time (if (not (file-exists? currency-file))
0
(stat:mtime (stat currency-file)))))
(if (< currency-time (- current-time seconds-in-a-day))
;; Use next-minute to avoid overwhelming the system in case of failure.
(next-minute)