Skip to content

Commit 4472095

Browse files
paulrdbbatsov
authored andcommitted
check if cache file exists
1 parent 4b5d3f0 commit 4472095

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/refactor_nrepl/artifacts.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
(if (zero? lm) nil lm)))
2323

2424
;; structure here is {"prismatic/schem" ["0.1.1" "0.2.0" ...]}
25-
(defonce artifacts (atom (slurp artifacts-file)
25+
(defonce artifacts (atom (if (.exists (io/as-file artifacts-file))
26+
(-> artifacts-file slurp read-string)
27+
{})
2628
:meta {:last-modified
2729
(get-last-modified-from-file artifacts-file)}))
2830
(def millis-per-day (* 24 60 60 1000))
@@ -116,8 +118,7 @@
116118
(defn artifact-list
117119
[{:keys [force]}]
118120
(when (or (= force "true") (stale-cache?))
119-
(update-artifact-cache!)
120-
(spit artifacts-file @artifacts))
121+
(update-artifact-cache!))
121122
(->> @artifacts keys list*))
122123

123124
(defn artifact-versions

0 commit comments

Comments
 (0)