mirror of
https://github.com/penpot/penpot.git
synced 2025-02-05 22:09:06 -05:00
✨ Use a prefixed dir for storing temp files
And mark them for deletion on JVM exit.
This commit is contained in:
parent
9649878fd8
commit
a31be7e2ff
14 changed files with 32 additions and 27 deletions
|
@ -44,7 +44,7 @@
|
|||
[clojure.walk :refer [macroexpand-all]]
|
||||
[criterium.core :as crit]
|
||||
[cuerdas.core :as str]
|
||||
[datoteka.core]
|
||||
[datoteka.fs :as fs]
|
||||
[integrant.core :as ig]
|
||||
[malli.core :as m]
|
||||
[malli.dev.pretty :as mdp]
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
[promesa.exec :as px]
|
||||
[promesa.exec.csp :as sp]))
|
||||
|
||||
(def default-tmp-dir "/tmp/penpot")
|
||||
|
||||
(declare ^:private remove-temp-file)
|
||||
(declare ^:private io-loop)
|
||||
|
||||
|
@ -33,6 +35,7 @@
|
|||
|
||||
(defmethod ig/init-key ::cleaner
|
||||
[_ cfg]
|
||||
(fs/create-dir default-tmp-dir)
|
||||
(px/fn->thread (partial io-loop cfg)
|
||||
{:name "penpot/storage/tmp-cleaner" :virtual true}))
|
||||
|
||||
|
@ -70,18 +73,14 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn tempfile
|
||||
"Returns a tmpfile candidate (without creating it)"
|
||||
[& {:keys [suffix prefix min-age]
|
||||
:or {prefix "penpot."
|
||||
suffix ".tmp"}}]
|
||||
(let [path (fs/tempfile :suffix suffix :prefix prefix)]
|
||||
(sp/offer! queue [path (some-> min-age dt/duration)])
|
||||
path))
|
||||
|
||||
(defn create-tempfile
|
||||
[& {:keys [suffix prefix min-age]
|
||||
:or {prefix "penpot."
|
||||
suffix ".tmp"}}]
|
||||
(let [path (fs/create-tempfile :suffix suffix :prefix prefix)]
|
||||
(let [path (fs/create-tempfile
|
||||
:perms "rw-r--r--"
|
||||
:dir default-tmp-dir
|
||||
:suffix suffix
|
||||
:prefix prefix)]
|
||||
(fs/delete-on-exit! path)
|
||||
(sp/offer! queue [path (some-> min-age dt/duration)])
|
||||
path))
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
[clojure.spec.alpha :as s]
|
||||
[clojure.test :as t]
|
||||
[cuerdas.core :as str]
|
||||
[datoteka.core :as fs]
|
||||
[datoteka.fs :as fs]
|
||||
[environ.core :refer [env]]
|
||||
[expound.alpha :as expound]
|
||||
[integrant.core :as ig]
|
||||
|
@ -127,6 +127,8 @@
|
|||
app.auth/verify-password (fn [a b] {:valid (= a b)})
|
||||
app.common.features/get-enabled-features (fn [& _] app.common.features/supported-features)]
|
||||
|
||||
(fs/create-dir "/tmp/penpot")
|
||||
|
||||
(let [templates [{:id "test"
|
||||
:name "test"
|
||||
:file-uri "test"
|
||||
|
@ -191,6 +193,7 @@
|
|||
(let [path (fs/path "/tmp/penpot")]
|
||||
(when (fs/exists? path)
|
||||
(fs/delete (fs/path "/tmp/penpot")))
|
||||
(fs/create-dir "/tmp/penpot")
|
||||
(next)))
|
||||
|
||||
(defn serial
|
||||
|
@ -496,7 +499,7 @@
|
|||
(defn tempfile
|
||||
[source]
|
||||
(let [rsc (io/resource source)
|
||||
tmp (fs/create-tempfile)]
|
||||
tmp (fs/create-tempfile :dir "/tmp/penpot" :prefix "test-")]
|
||||
(io/copy (io/file rsc)
|
||||
(io/file tmp))
|
||||
tmp))
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
[app.util.time :as dt]
|
||||
[backend-tests.helpers :as th]
|
||||
[clojure.test :as t]
|
||||
[datoteka.core :as fs]
|
||||
[datoteka.fs :as fs]
|
||||
[mockery.core :refer [with-mocks]]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
[backend-tests.helpers :as th]
|
||||
[backend-tests.storage-test :refer [configure-storage-backend]]
|
||||
[clojure.test :as t]
|
||||
[datoteka.core :as fs]))
|
||||
[datoteka.fs :as fs]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
(t/use-fixtures :each th/database-reset)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
[clojure.java.io :as io]
|
||||
[clojure.test :as t]
|
||||
[cuerdas.core :as str]
|
||||
[datoteka.core :as fs]
|
||||
[datoteka.fs :as fs]
|
||||
[mockery.core :refer [with-mocks]]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
[backend-tests.storage-test :refer [configure-storage-backend]]
|
||||
[buddy.core.bytes :as b]
|
||||
[clojure.test :as t]
|
||||
[datoteka.core :as fs]))
|
||||
[datoteka.fs :as fs]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
(t/use-fixtures :each th/database-reset)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
[app.storage :as sto]
|
||||
[backend-tests.helpers :as th]
|
||||
[clojure.test :as t]
|
||||
[datoteka.core :as fs]))
|
||||
[datoteka.fs :as fs]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
(t/use-fixtures :each th/database-reset)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
[clojure.java.io :as io]
|
||||
[clojure.test :as t]
|
||||
[cuerdas.core :as str]
|
||||
[datoteka.core :as fs]
|
||||
[datoteka.fs :as fs]
|
||||
[mockery.core :refer [with-mocks]]))
|
||||
|
||||
;; TODO: profile deletion with teams
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
[app.rpc.quotes :as-alias quotes]
|
||||
[backend-tests.helpers :as th]
|
||||
[clojure.test :as t]
|
||||
[datoteka.core :as fs]
|
||||
[datoteka.fs :as fs]
|
||||
[mockery.core :refer [with-mocks]]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
[app.util.time :as dt]
|
||||
[backend-tests.helpers :as th]
|
||||
[clojure.test :as t]
|
||||
[datoteka.core :as fs]
|
||||
[datoteka.fs :as fs]
|
||||
[mockery.core :refer [with-mocks]]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
[app.rpc :as-alias rpc]
|
||||
[backend-tests.helpers :as th]
|
||||
[clojure.test :as t]
|
||||
[datoteka.core :as fs]))
|
||||
[datoteka.fs :as fs]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
(t/use-fixtures :each th/database-reset)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
[backend-tests.helpers :as th]
|
||||
[clojure.test :as t]
|
||||
[cuerdas.core :as str]
|
||||
[datoteka.core :as fs]
|
||||
[datoteka.fs :as fs]
|
||||
[datoteka.io :as io]
|
||||
[mockery.core :refer [with-mocks]]))
|
||||
|
||||
|
|
|
@ -32,11 +32,14 @@
|
|||
|
||||
funcool/tubax {:mvn/version "2021.05.20-0"}
|
||||
funcool/cuerdas {:mvn/version "2023.11.09-407"}
|
||||
funcool/promesa {:git/sha "0c5ed6ad033515a2df4b55addea044f60e9653d0"
|
||||
:git/url "https://github.com/funcool/promesa"}
|
||||
funcool/promesa
|
||||
{:git/sha "0c5ed6ad033515a2df4b55addea044f60e9653d0"
|
||||
:git/url "https://github.com/funcool/promesa"}
|
||||
|
||||
funcool/datoteka {:mvn/version "3.0.66"
|
||||
:exclusions [funcool/promesa]}
|
||||
funcool/datoteka
|
||||
{:git/sha "5ac3781"
|
||||
:git/tag "3.0.0"
|
||||
:git/url "https://github.com/funcool/datoteka"}
|
||||
|
||||
lambdaisland/uri {:mvn/version "1.16.134"
|
||||
:exclusions [org.clojure/data.json]}
|
||||
|
|
Loading…
Add table
Reference in a new issue