From ebe8fdcba81f71aecf38ce55410bb46cdea80952 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 29 Jun 2022 14:39:40 +0200 Subject: [PATCH 1/3] :recycle: Refactor temporal files management on exporter --- exporter/src/app/core.cljs | 2 +- exporter/src/app/handlers/export_frames.cljs | 5 +-- exporter/src/app/handlers/export_shapes.cljs | 4 -- exporter/src/app/handlers/resources.cljs | 4 +- exporter/src/app/renderer/bitmap.cljs | 5 +-- exporter/src/app/renderer/pdf.cljs | 3 +- exporter/src/app/renderer/svg.cljs | 32 +++++---------- exporter/src/app/util/shell.cljs | 42 ++++++++++++++++++-- 8 files changed, 57 insertions(+), 40 deletions(-) diff --git a/exporter/src/app/core.cljs b/exporter/src/app/core.cljs index c3ebbd46a..79597412d 100644 --- a/exporter/src/app/core.cljs +++ b/exporter/src/app/core.cljs @@ -8,10 +8,10 @@ (:require ["process" :as proc] [app.browser :as bwr] - [app.redis :as redis] [app.common.logging :as l] [app.config] [app.http :as http] + [app.redis :as redis] [promesa.core :as p])) (enable-console-print!) diff --git a/exporter/src/app/handlers/export_frames.cljs b/exporter/src/app/handlers/export_frames.cljs index a8a4a0c85..716cc0b30 100644 --- a/exporter/src/app/handlers/export_frames.cljs +++ b/exporter/src/app/handlers/export_frames.cljs @@ -128,8 +128,8 @@ (defn- join-pdf [file-id paths] - (p/let [tmpdir (sh/mktmpdir! "join-pdf") - path (path/join tmpdir (str/concat file-id ".pdf"))] + (p/let [prefix (str/concat "penpot.tmp.pdfunite." file-id ".") + path (sh/tempfile :prefix prefix :suffix ".pdf")] (sh/run-cmd! (str "pdfunite " (str/join " " paths) " " path)) path)) @@ -137,5 +137,4 @@ [{:keys [path] :as resource} output-path] (p/do (sh/move! output-path path) - (sh/rmdir! (path/dirname output-path)) resource)) diff --git a/exporter/src/app/handlers/export_shapes.cljs b/exporter/src/app/handlers/export_shapes.cljs index c6ac2f05d..d50dfc7c3 100644 --- a/exporter/src/app/handlers/export_shapes.cljs +++ b/exporter/src/app/handlers/export_shapes.cljs @@ -102,8 +102,6 @@ total (count exports) topic (str profile-id) - to-delete (atom #{}) - on-progress (fn [{:keys [done]}] (when-not wait (let [data {:type :export-update @@ -137,7 +135,6 @@ :on-progress on-progress) append (fn [{:keys [filename path] :as object}] - (swap! to-delete conj path) (rsc/add-to-zip! zip path filename)) proc (-> (p/do @@ -146,7 +143,6 @@ (p/let [proc (rd/render export append)] (p/recur (rest exports))))) (.finalize zip)) - (p/then (fn [_] (p/run! #(sh/rmdir! (path/dirname %)) @to-delete))) (p/then (constantly resource)) (p/catch on-error)) ] diff --git a/exporter/src/app/handlers/resources.cljs b/exporter/src/app/handlers/resources.cljs index e02705610..02ccfe0b1 100644 --- a/exporter/src/app/handlers/resources.cljs +++ b/exporter/src/app/handlers/resources.cljs @@ -14,15 +14,15 @@ [app.common.data :as d] [app.common.exceptions :as ex] [app.common.uuid :as uuid] - [app.util.shell :as sh] [app.util.mime :as mime] + [app.util.shell :as sh] [cljs.core :as c] [cuerdas.core :as str] [promesa.core :as p])) (defn- get-path [type id] - (path/join (os/tmpdir) (str/concat "exporter-resource." (c/name type) "." id))) + (path/join sh/tmpdir (str/concat "penpot.resource." (c/name type) "." id))) (defn create "Generates ephimeral resource object." diff --git a/exporter/src/app/renderer/bitmap.cljs b/exporter/src/app/renderer/bitmap.cljs index eaee73346..bacde909b 100644 --- a/exporter/src/app/renderer/bitmap.cljs +++ b/exporter/src/app/renderer/bitmap.cljs @@ -36,9 +36,8 @@ :userAgent bw/default-user-agent}) (render-object [page {:keys [id] :as object}] - (p/let [tmpdir (sh/mktmpdir! "bitmap-render") - path (path/join tmpdir (str/concat id (mime/get-extension type))) - node (bw/select page (str/concat "#screenshot-" id))] + (p/let [path (sh/tempfile :prefix "penpot.tmp.render.bitmap." :suffix (mime/get-extension type)) + node (bw/select page (str/concat "#screenshot-" id))] (bw/wait-for node) (case type :png (bw/screenshot node {:omit-background? true :type type :path path}) diff --git a/exporter/src/app/renderer/pdf.cljs b/exporter/src/app/renderer/pdf.cljs index 124e545ad..2ba6926e8 100644 --- a/exporter/src/app/renderer/pdf.cljs +++ b/exporter/src/app/renderer/pdf.cljs @@ -44,8 +44,7 @@ (render-object [page base-uri {:keys [id] :as object}] (p/let [uri (prepare-uri base-uri id) - tmp (sh/mktmpdir! "pdf-render") - path (path/join tmp (str/concat id (mime/get-extension type)))] + path (sh/tempfile :prefix "penpot.tmp.render.pdf." :suffix (mime/get-extension type))] (l/info :uri uri) (bw/nav! page uri) (p/let [dom (bw/select page (dm/str "#screenshot-" id))] diff --git a/exporter/src/app/renderer/svg.cljs b/exporter/src/app/renderer/svg.cljs index 825c51ad9..d1c4e3fcc 100644 --- a/exporter/src/app/renderer/svg.cljs +++ b/exporter/src/app/renderer/svg.cljs @@ -116,24 +116,20 @@ (defn render [{:keys [page-id file-id objects token scale type]} on-object] (letfn [(convert-to-ppm [pngpath] - (l/trace :fn :convert-to-ppm) - (let [basepath (path/dirname pngpath) - ppmpath (path/join basepath "origin.ppm")] + (let [ppmpath (str/concat pngpath "origin.ppm")] + (l/trace :fn :convert-to-ppm :path ppmpath) (-> (sh/run-cmd! (str "convert " pngpath " " ppmpath)) (p/then (constantly ppmpath))))) (trace-color-mask [pbmpath] (l/trace :fn :trace-color-mask :pbmpath pbmpath) - (let [basepath (path/dirname pbmpath) - basename (path/basename pbmpath ".pbm") - svgpath (path/join basepath (str basename ".svg"))] + (let [svgpath (str/concat pbmpath ".svg")] (-> (sh/run-cmd! (str "potrace --flat -b svg " pbmpath " -o " svgpath)) (p/then (constantly svgpath))))) (generate-color-layer [ppmpath color] (l/trace :fn :generate-color-layer :ppmpath ppmpath :color color) - (let [basepath (path/dirname ppmpath) - pbmpath (path/join basepath (str "mask-" (subs color 1) ".pbm"))] + (let [pbmpath (str/concat ppmpath ".mask-" (subs color 1) ".pbm")] (-> (sh/run-cmd! (str/format "ppmcolormask \"%s\" %s" color ppmpath)) (p/then (fn [stdout] (-> (sh/write-file! pbmpath stdout) @@ -247,15 +243,14 @@ (trace-node [{:keys [data] :as node}] (l/trace :fn :trace-node) - (p/let [tdpath (sh/mktmpdir! "svgexport") - pngpath (path/join tdpath "origin.png") + (p/let [pngpath (sh/tempfile :prefix "penpot.tmp.render.svg.parse." + :suffix ".origin.png") _ (sh/write-file! pngpath data) ppmpath (convert-to-ppm pngpath) svgdata (convert-to-svg ppmpath node)] (-> node (dissoc :data) - (assoc :tempdir tdpath - :svgdata svgdata)))) + (assoc :svgdata svgdata)))) (extract-element-attrs [^js element] (let [^js attrs (.. element -attributes) @@ -289,17 +284,11 @@ shot (bw/screenshot text-node {:omit-background? true :type "png"})] [shot node])) - (clean-temp-data [{:keys [tempdir] :as node}] - (p/do! - (sh/rmdir! tempdir) - (dissoc node :tempdir))) - (extract-txt-node [page item] (-> (p/resolved item) (p/then (partial resolve-text-node page)) (p/then extract-single-node) - (p/then trace-node) - (p/then clean-temp-data))) + (p/then trace-node))) (extract-txt-nodes [page {:keys [id] :as objects}] (l/trace :fn :process-text-nodes) @@ -323,9 +312,8 @@ :userAgent bw/default-user-agent}) (render-object [page {:keys [id] :as object}] - (p/let [tmpdir (sh/mktmpdir! "svg-render") - path (path/join tmpdir (str/concat id (mime/get-extension type))) - node (bw/select page (str/concat "#screenshot-" id))] + (p/let [path (sh/tempfile :prefix "penpot.tmp.render.svg." :suffix (mime/get-extension type)) + node (bw/select page (str/concat "#screenshot-" id))] (bw/wait-for node) (p/let [xmldata (extract-svg page object) txtdata (extract-txt-nodes page object) diff --git a/exporter/src/app/util/shell.cljs b/exporter/src/app/util/shell.cljs index 93b5333ed..559174167 100644 --- a/exporter/src/app/util/shell.cljs +++ b/exporter/src/app/util/shell.cljs @@ -12,13 +12,49 @@ ["os" :as os] ["path" :as path] [app.common.logging :as l] + [app.common.uuid :as uuid] + [app.common.exceptions :as ex] + [cuerdas.core :as str] [promesa.core :as p])) (l/set-level! :trace) -(defn mktmpdir! - [prefix] - (.mkdtemp fs/promises (path/join (os/tmpdir) prefix))) +(def tempfile-minage (* 1000 60 60 1)) ;; 1h + +(def tmpdir + (let [path (path/join (os/tmpdir) "penpot")] + (when-not (fs/existsSync path) + (fs/mkdirSync path #js {:recursive true})) + path)) + + +(defn- schedule-deletion! + [path] + (letfn [(remote-tempfile [] + (when (fs/existsSync path) + (l/trace :hint "permanently remove tempfile" :path path) + (fs/rmSync path #js {:recursive true})))] + (let [ts (js/Date.now)] + (l/trace :hint "schedule tempfile deletion" + :path path + :scheduled-at (.. (js/Date. (+ (js/Date.now) tempfile-minage)) toString)) + (js/setTimeout remote-tempfile tempfile-minage)))) + +(defn tempfile + [& {:keys [prefix suffix] + :or {prefix "penpot." + suffix ".tmp"}}] + (loop [i 0] + (if (< i 1000) + (let [path (path/join tmpdir (str/concat prefix (uuid/next) "-" i suffix))] + (if (fs/existsSync path) + (recur (inc i)) + (do + (schedule-deletion! path) + path))) + (ex/raise :type :internal + :code :unable-to-locate-temporal-file + :hint "unable to find a tempfile candidate")))) (defn move! [origin-path dest-path] From 9c194ee3cb2a98a14bc56523cf224ad6f2b01328 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 29 Jun 2022 14:39:56 +0200 Subject: [PATCH 2/3] :bug: Fix websocket unexpected exception on exportation module A regression caused by the previous commit that refactos the websockets API and its state management. --- frontend/src/app/main/data/websocket.cljs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/src/app/main/data/websocket.cljs b/frontend/src/app/main/data/websocket.cljs index 3612770d4..a0b552393 100644 --- a/frontend/src/app/main/data/websocket.cljs +++ b/frontend/src/app/main/data/websocket.cljs @@ -55,6 +55,7 @@ (rx/filter (ptk/type? ::initialize) stream))] (->> (rx/merge + (rx/of #(assoc % :ws-conn ws)) (->> (ws/get-rcv-stream ws) (rx/filter ws/message-event?) (rx/map :payload) @@ -69,6 +70,10 @@ (defn finalize [] (ptk/reify ::finalize + ptk/UpdateEvent + (update [_ state] + (dissoc state :ws-conn)) + ptk/EffectEvent (effect [_ _ _] (l/trace :hint "event:finalize" :fn "effect") From bfb0ba47f5860311a0d19da879a6505baf51b13d Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 29 Jun 2022 14:53:57 +0200 Subject: [PATCH 3/3] :lipstick: Fix linter issues on exporter --- exporter/src/app/browser.cljs | 2 -- exporter/src/app/config.cljs | 3 --- exporter/src/app/core.cljs | 2 +- exporter/src/app/handlers.cljs | 8 ++------ exporter/src/app/handlers/export_frames.cljs | 12 +++++------- exporter/src/app/handlers/export_shapes.cljs | 5 ++--- exporter/src/app/handlers/resources.cljs | 4 +--- exporter/src/app/http.cljs | 1 - exporter/src/app/redis.cljs | 2 +- exporter/src/app/renderer.cljs | 2 +- exporter/src/app/renderer/bitmap.cljs | 7 ------- exporter/src/app/renderer/pdf.cljs | 8 +------- exporter/src/app/renderer/svg.cljs | 10 ++-------- exporter/src/app/util/mime.cljs | 3 +-- exporter/src/app/util/shell.cljs | 13 ++++++------- 15 files changed, 23 insertions(+), 59 deletions(-) diff --git a/exporter/src/app/browser.cljs b/exporter/src/app/browser.cljs index 588b12749..c885a3d45 100644 --- a/exporter/src/app/browser.cljs +++ b/exporter/src/app/browser.cljs @@ -9,10 +9,8 @@ ["generic-pool" :as gp] ["generic-pool/lib/errors" :as gpe] ["playwright" :as pw] - [app.common.data :as d] [app.common.exceptions :as ex] [app.common.logging :as l] - [app.common.uuid :as uuid] [app.config :as cf] [app.util.object :as obj] [promesa.core :as p])) diff --git a/exporter/src/app/config.cljs b/exporter/src/app/config.cljs index 6a312ab68..2d8729c6d 100644 --- a/exporter/src/app/config.cljs +++ b/exporter/src/app/config.cljs @@ -7,13 +7,10 @@ (ns app.config (:refer-clojure :exclude [get]) (:require - ["fs" :as fs] ["process" :as process] - [app.common.exceptions :as ex] [app.common.data :as d] [app.common.spec :as us] [app.common.version :as v] - [app.common.uri :as u] [cljs.core :as c] [cljs.pprint] [cljs.spec.alpha :as s] diff --git a/exporter/src/app/core.cljs b/exporter/src/app/core.cljs index 79597412d..453ff720b 100644 --- a/exporter/src/app/core.cljs +++ b/exporter/src/app/core.cljs @@ -18,7 +18,7 @@ (l/initialize!) (defn start - [& args] + [& _] (l/info :msg "initializing") (p/do! (bwr/init) diff --git a/exporter/src/app/handlers.cljs b/exporter/src/app/handlers.cljs index a1a849699..14d6a862e 100644 --- a/exporter/src/app/handlers.cljs +++ b/exporter/src/app/handlers.cljs @@ -10,22 +10,18 @@ [app.common.exceptions :as ex] [app.common.logging :as l] [app.common.spec :as us] - [app.common.uri :as u] - [app.config :as cf] [app.handlers.export-frames :as export-frames] [app.handlers.export-shapes :as export-shapes] [app.handlers.resources :as resources] [app.util.transit :as t] [clojure.spec.alpha :as s] - [cuerdas.core :as str] - [promesa.core :as p] - [reitit.core :as r])) + [cuerdas.core :as str])) (l/set-level! :debug) (defn on-error [error exchange] - (let [{:keys [type message code] :as data} (ex-data error)] + (let [{:keys [type code] :as data} (ex-data error)] (cond (or (= :validation type) (= :assertion type)) diff --git a/exporter/src/app/handlers/export_frames.cljs b/exporter/src/app/handlers/export_frames.cljs index 716cc0b30..0c9816710 100644 --- a/exporter/src/app/handlers/export_frames.cljs +++ b/exporter/src/app/handlers/export_frames.cljs @@ -6,13 +6,10 @@ (ns app.handlers.export-frames (:require - ["path" :as path] [app.common.logging :as l] - [app.common.exceptions :as exc] [app.common.spec :as us] - [app.common.pprint :as pp] - [app.handlers.resources :as rsc] [app.handlers.export-shapes :refer [prepare-exports]] + [app.handlers.resources :as rsc] [app.redis :as redis] [app.renderer :as rd] [app.util.shell :as sh] @@ -41,7 +38,7 @@ :opt-un [::name])) (defn handler - [{:keys [:request/auth-token] :as exchange} {:keys [exports profile-id] :as params}] + [{:keys [:request/auth-token] :as exchange} {:keys [exports] :as params}] ;; NOTE: we need to have the `:type` prop because the exports ;; datastructure preparation uses it for creating the groups. (let [exports (-> (map #(assoc % :type :pdf :scale 1 :suffix "") exports) @@ -111,7 +108,8 @@ (-> (p/loop [exports (seq exports)] (when-let [export (first exports)] - (p/let [proc (rd/render export on-object)] + (p/do + (rd/render export on-object) (p/recur (rest exports))))) (p/then (fn [_] (deref result))) @@ -122,7 +120,7 @@ (-> (sh/stat (:path resource)) (p/then #(merge resource %))))) (p/catch on-error) - (p/finally (fn [result cause] + (p/finally (fn [_ cause] (when-not cause (on-complete))))))) diff --git a/exporter/src/app/handlers/export_shapes.cljs b/exporter/src/app/handlers/export_shapes.cljs index d50dfc7c3..02e7a824d 100644 --- a/exporter/src/app/handlers/export_shapes.cljs +++ b/exporter/src/app/handlers/export_shapes.cljs @@ -6,9 +6,7 @@ (ns app.handlers.export-shapes (:require - ["path" :as path] [app.common.data :as d] - [app.common.exceptions :as exc] [app.common.logging :as l] [app.common.spec :as us] [app.handlers.resources :as rsc] @@ -140,7 +138,8 @@ proc (-> (p/do (p/loop [exports (seq exports)] (when-let [export (first exports)] - (p/let [proc (rd/render export append)] + (p/do + (rd/render export append) (p/recur (rest exports))))) (.finalize zip)) (p/then (constantly resource)) diff --git a/exporter/src/app/handlers/resources.cljs b/exporter/src/app/handlers/resources.cljs index 02ccfe0b1..c6729b08f 100644 --- a/exporter/src/app/handlers/resources.cljs +++ b/exporter/src/app/handlers/resources.cljs @@ -9,9 +9,7 @@ (:require ["archiver" :as arc] ["fs" :as fs] - ["os" :as os] ["path" :as path] - [app.common.data :as d] [app.common.exceptions :as ex] [app.common.uuid :as uuid] [app.util.mime :as mime] @@ -49,7 +47,7 @@ "content-length" (:size stat)}})) (defn handler - [{:keys [:request/params response] :as exchange}] + [{:keys [:request/params] :as exchange}] (when-not (contains? params :id) (ex/raise :type :validation :code :missing-id)) diff --git a/exporter/src/app/http.cljs b/exporter/src/app/http.cljs index 1e3512ab7..062191169 100644 --- a/exporter/src/app/http.cljs +++ b/exporter/src/app/http.cljs @@ -12,7 +12,6 @@ ["raw-body" :as raw-body] ["stream" :as stream] [app.common.logging :as l] - [app.common.spec :as us] [app.common.transit :as t] [app.config :as cf] [app.handlers :as handlers] diff --git a/exporter/src/app/redis.cljs b/exporter/src/app/redis.cljs index 5d704bc86..10b095cf4 100644 --- a/exporter/src/app/redis.cljs +++ b/exporter/src/app/redis.cljs @@ -28,7 +28,7 @@ (.on client "reconnect" (fn [ms] (l/warn :hint "reconnecting to redis" :ms ms))) (.on client "end" - (fn [ms] (l/warn :hint "client ended, no more connections will be attempted"))) + (fn [] (l/warn :hint "client ended, no more connections will be attempted"))) client)) (defn init diff --git a/exporter/src/app/renderer.cljs b/exporter/src/app/renderer.cljs index 42ab6c6ad..63f1367f5 100644 --- a/exporter/src/app/renderer.cljs +++ b/exporter/src/app/renderer.cljs @@ -31,7 +31,7 @@ (s/def ::render-params (s/keys :req-un [::file-id ::page-id ::scale ::token ::type ::objects])) -(defn- render +(defn render [{:keys [type] :as params} on-object] (us/verify ::render-params params) (us/verify fn? on-object) diff --git a/exporter/src/app/renderer/bitmap.cljs b/exporter/src/app/renderer/bitmap.cljs index bacde909b..959da4877 100644 --- a/exporter/src/app/renderer/bitmap.cljs +++ b/exporter/src/app/renderer/bitmap.cljs @@ -7,19 +7,12 @@ (ns app.renderer.bitmap "A bitmap renderer." (:require - ["path" :as path] [app.browser :as bw] - [app.common.data :as d] - [app.common.data.macros :as dm] - [app.common.exceptions :as ex] [app.common.logging :as l] - [app.common.pages :as cp] - [app.common.spec :as us] [app.common.uri :as u] [app.config :as cf] [app.util.mime :as mime] [app.util.shell :as sh] - [cljs.spec.alpha :as s] [cuerdas.core :as str] [promesa.core :as p])) diff --git a/exporter/src/app/renderer/pdf.cljs b/exporter/src/app/renderer/pdf.cljs index 2ba6926e8..14d9be40a 100644 --- a/exporter/src/app/renderer/pdf.cljs +++ b/exporter/src/app/renderer/pdf.cljs @@ -7,18 +7,13 @@ (ns app.renderer.pdf "A pdf renderer." (:require - ["path" :as path] [app.browser :as bw] [app.common.data.macros :as dm] - [app.common.exceptions :as ex :include-macros true] [app.common.logging :as l] - [app.common.spec :as us] [app.common.uri :as u] [app.config :as cf] [app.util.mime :as mime] [app.util.shell :as sh] - [cuerdas.core :as str] - [cljs.spec.alpha :as s] [promesa.core :as p])) (defn render @@ -57,8 +52,7 @@ (render [base-uri page] (p/loop [objects (seq objects)] (when-let [object (first objects)] - (p/let [uri (prepare-uri base-uri (:id object)) - path (render-object page base-uri object)] + (p/let [path (render-object page base-uri object)] (on-object (assoc object :path path)) (p/recur (rest objects))))))] diff --git a/exporter/src/app/renderer/svg.cljs b/exporter/src/app/renderer/svg.cljs index d1c4e3fcc..39cd8d17c 100644 --- a/exporter/src/app/renderer/svg.cljs +++ b/exporter/src/app/renderer/svg.cljs @@ -6,20 +6,14 @@ (ns app.renderer.svg (:require - ["path" :as path] ["xml-js" :as xml] [app.browser :as bw] [app.common.data :as d] - [app.common.data.macros :as dm] - [app.common.exceptions :as ex :include-macros true] [app.common.logging :as l] - [app.common.pages :as cp] - [app.common.spec :as us] [app.common.uri :as u] [app.config :as cf] [app.util.mime :as mime] [app.util.shell :as sh] - [cljs.spec.alpha :as s] [clojure.walk :as walk] [cuerdas.core :as str] [promesa.core :as p])) @@ -184,7 +178,7 @@ (get-gradients [id mapping] (->> mapping - (filter (fn [[color data]] + (filter (fn [[_color data]] (= (get data "type") "gradient"))) (mapv (partial data->gradient-def id)))) @@ -227,7 +221,7 @@ elements (cond->> elements - (not (empty? gradient-defs)) + (seq gradient-defs) (into [{"type" "element" "name" "defs" "attributes" {} "elements" gradient-defs}]))] diff --git a/exporter/src/app/util/mime.cljs b/exporter/src/app/util/mime.cljs index ed5a19a4c..fef7e4053 100644 --- a/exporter/src/app/util/mime.cljs +++ b/exporter/src/app/util/mime.cljs @@ -8,7 +8,6 @@ "Mimetype and file extension helpers." (:refer-clojure :exclude [get]) (:require - [app.common.data :as d] [cljs.core :as c])) (defn get-extension @@ -20,7 +19,7 @@ :pdf ".pdf" :zip ".zip")) -(defn- get +(defn get [type] (case type :zip "application/zip" diff --git a/exporter/src/app/util/shell.cljs b/exporter/src/app/util/shell.cljs index 559174167..fcb36b981 100644 --- a/exporter/src/app/util/shell.cljs +++ b/exporter/src/app/util/shell.cljs @@ -11,9 +11,9 @@ ["fs" :as fs] ["os" :as os] ["path" :as path] + [app.common.exceptions :as ex] [app.common.logging :as l] [app.common.uuid :as uuid] - [app.common.exceptions :as ex] [cuerdas.core :as str] [promesa.core :as p])) @@ -34,11 +34,10 @@ (when (fs/existsSync path) (l/trace :hint "permanently remove tempfile" :path path) (fs/rmSync path #js {:recursive true})))] - (let [ts (js/Date.now)] - (l/trace :hint "schedule tempfile deletion" - :path path - :scheduled-at (.. (js/Date. (+ (js/Date.now) tempfile-minage)) toString)) - (js/setTimeout remote-tempfile tempfile-minage)))) + (l/trace :hint "schedule tempfile deletion" + :path path + :scheduled-at (.. (js/Date. (+ (js/Date.now) tempfile-minage)) toString)) + (js/setTimeout remote-tempfile tempfile-minage))) (defn tempfile [& {:keys [prefix suffix] @@ -86,7 +85,7 @@ (fn [resolve reject] (l/trace :fn :run-cmd :cmd cmd) (proc/exec cmd #js {:encoding "buffer"} - (fn [error stdout stderr] + (fn [error stdout _stderr] ;; (l/trace :fn :run-cmd :stdout stdout) (if error (reject error)