Skip to content

Commit b2d1665

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

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/clj/metafacture_playground/process.clj

Lines changed: 16 additions & 4 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)
@@ -30,7 +31,18 @@
3031
"default transformationFile = \"" transformationFile "\";\n"
3132
flux)
3233
(clj-str/replace #"\|(\s*|\n*)write\(\".*\"\)(\s*|\n*);" output)
33-
(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)))
34+
(clj-str/replace #"\|(\s*|\n*)print(\s*|\n*);" output))
35+
fluxfile (content->tempfile-path flux ".flux")]
36+
(try
37+
(Flux/main (into-array [fluxfile]))
38+
(log/info "Executed flux file with Flux/main. Result in" out-path)
39+
(slurp out-path)
40+
(finally
41+
;; Remove temp files
42+
(doseq [f [inputfile transformationFile fluxfile out-path]]
43+
(try
44+
(let [file (io/file f)]
45+
(when (.exists file)
46+
(io/delete-file file true)))
47+
(catch Exception e
48+
(log/warn "Could not delete temp file:" f e))))))))

0 commit comments

Comments
 (0)