Changeset View
Changeset View
Standalone View
Standalone View
src/main/phabricator/utils.lisp
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | |||||
(let | (let | ||||
((cache-path (gensym)) | ((cache-path (gensym)) | ||||
(obj (gensym))) | (obj (gensym))) | ||||
`(let | `(let | ||||
((,cache-path (format nil "~A/~A/~A" *working-directory* ,dir ,id))) | ((,cache-path (format nil "~A/~A/~A" *working-directory* ,dir ,id))) | ||||
(ensure-directories-exist ,cache-path) | (ensure-directories-exist ,cache-path) | ||||
(if | (if | ||||
(and (probe-file ,cache-path) (not ,override-cache) (not *override-cache*)) | (and (probe-file ,cache-path) (not ,override-cache) (not *override-cache*)) | ||||
(with-open-file (str ,cache-path) (read str)) | (let ((data (with-open-file (str ,cache-path) (read str)))) | ||||
(if data ;; let's check if the data is non nil | |||||
data ;; and return it | |||||
;; otherwise, fallbacks to fetch data again and overwrite it | |||||
(let | |||||
((,obj ,item)) | |||||
(with-open-file (str ,cache-path :direction :output :if-exists :supersede) | |||||
(format str "~S" ,obj)) | |||||
,obj))) | |||||
(let | (let | ||||
((,obj ,item)) | ((,obj ,item)) | ||||
(with-open-file (str ,cache-path :direction :output :if-exists :supersede) | (with-open-file (str ,cache-path :direction :output :if-exists :supersede) | ||||
(format str "~S" ,obj)) | (format str "~S" ,obj)) | ||||
,obj))))) | ,obj))))) |