Skip to content

Commit 5b34b81

Browse files
committed
at least log an error when delete-file fails
I could fix the issue by forcing an out of memory error since that also forces garbage collection. But I'm not ready for that yet... see boot-clj#117 and boot-clj#138
1 parent 4e5a266 commit 5b34b81

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

boot/pod/src/boot/file.clj

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@
2929
(defmacro guard [& exprs]
3030
`(try (do ~@exprs) (catch Throwable _#)))
3131

32+
(defn delete-file
33+
[f]
34+
(try
35+
(io/delete-file f)
36+
(catch Exception err
37+
(println "ERROR deleting" f err))))
38+
3239
(defn clean! [& files]
3340
(doseq [f files]
34-
(doall (->> f io/file file-seq (keep file?) (map #(io/delete-file % true))))))
41+
(doall (->> f io/file file-seq (keep file?) (map delete-file)))))
3542

3643
(defn empty-dir!
3744
[& dirs]
@@ -40,14 +47,14 @@
4047
(mapcat (comp rest file-seq))
4148
(group-by (memfn isFile)))
4249
to-rm (concat files (reverse dirs'))]
43-
(doseq [f to-rm] (io/delete-file f true))))
50+
(doseq [f to-rm] (delete-file f))))
4451

4552
(defn delete-empty-subdirs!
4653
[dir]
4754
(let [empty-dir? #(and (.isDirectory %) (empty? (.list %)))
4855
subdirs (->> dir io/file file-seq (filter (memfn isDirectory)))]
4956
(doseq [f (reverse subdirs)]
50-
(when (empty-dir? f) (io/delete-file f true)))))
57+
(when (empty-dir? f) (delete-file f)))))
5158

5259
(defn- contains-files?
5360
[dir]
@@ -161,7 +168,7 @@
161168
after (apply tree-for srcs)]
162169
(doseq [[op p x] (patch pred before after)]
163170
(case op
164-
:rm (io/delete-file x true)
171+
:rm (delete-file x)
165172
:cp (copy-with-lastmod x (io/file dest p))))))
166173

167174
(defn watcher! [pred & dirs]

0 commit comments

Comments
 (0)