Skip to content

Commit

Permalink
at least log an error when delete-file fails
Browse files Browse the repository at this point in the history
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 #117 and #138
  • Loading branch information
schmir committed Feb 23, 2015
1 parent 4e5a266 commit 5b34b81
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions boot/pod/src/boot/file.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
(defmacro guard [& exprs]
`(try (do ~@exprs) (catch Throwable _#)))

(defn delete-file
[f]
(try
(io/delete-file f)
(catch Exception err
(println "ERROR deleting" f err))))

(defn clean! [& files]
(doseq [f files]
(doall (->> f io/file file-seq (keep file?) (map #(io/delete-file % true))))))
(doall (->> f io/file file-seq (keep file?) (map delete-file)))))

(defn empty-dir!
[& dirs]
Expand All @@ -40,14 +47,14 @@
(mapcat (comp rest file-seq))
(group-by (memfn isFile)))
to-rm (concat files (reverse dirs'))]
(doseq [f to-rm] (io/delete-file f true))))
(doseq [f to-rm] (delete-file f))))

(defn delete-empty-subdirs!
[dir]
(let [empty-dir? #(and (.isDirectory %) (empty? (.list %)))
subdirs (->> dir io/file file-seq (filter (memfn isDirectory)))]
(doseq [f (reverse subdirs)]
(when (empty-dir? f) (io/delete-file f true)))))
(when (empty-dir? f) (delete-file f)))))

(defn- contains-files?
[dir]
Expand Down Expand Up @@ -161,7 +168,7 @@
after (apply tree-for srcs)]
(doseq [[op p x] (patch pred before after)]
(case op
:rm (io/delete-file x true)
:rm (delete-file x)
:cp (copy-with-lastmod x (io/file dest p))))))

(defn watcher! [pred & dirs]
Expand Down

0 comments on commit 5b34b81

Please sign in to comment.