Skip to content

Commit 5555abb

Browse files
committed
Remove all tmp files. Resolves #158
1 parent a2ba292 commit 5555abb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/clj/metafacture_playground/process.clj

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(ns metafacture-playground.process
22
(:require
33
[clojure.string :as clj-str]
4+
[clojure.java.io :as io]
45
[clojure.tools.logging :as log])
56
(:import
67
(java.io File)
@@ -31,6 +32,16 @@
3132
flux)
3233
(clj-str/replace #"\|(\s*|\n*)write\(\".*\"\)(\s*|\n*);" output)
3334
(clj-str/replace #"\|(\s*|\n*)print(\s*|\n*);" output))]
34-
(Flux/main (into-array [(content->tempfile-path flux ".flux")]))
35-
(log/info "Executed flux file with Flux/main. Result in" out-path)
36-
(slurp out-path)))
35+
(try
36+
(Flux/main (into-array [(content->tempfile-path flux ".flux")]))
37+
(log/info "Executed flux file with Flux/main. Result in" out-path)
38+
(slurp out-path)
39+
(finally
40+
;; Remove temp files
41+
(doseq [f [inputfile transformationFile fluxfile out-path]]
42+
(try
43+
(let [file (io/file f)]
44+
(when (.exists file)
45+
(io/delete-file file true)))
46+
(catch Exception e
47+
(log/warn "Could not delete temp file:" f e))))))))

0 commit comments

Comments
 (0)