mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
✨ Simplify tempfile deletion handling
Mainly removes the jvm on-exit hook usage because it can lead to slow stops and unnecesary memory consumption over the time the jvm is running.
This commit is contained in:
@@ -79,14 +79,17 @@
|
|||||||
;; API
|
;; API
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defn tempfile
|
(defn tempfile*
|
||||||
[& {:keys [suffix prefix min-age]
|
[& {:keys [suffix prefix]
|
||||||
:or {prefix "penpot."
|
:or {prefix "penpot."
|
||||||
suffix ".tmp"}}]
|
suffix ".tmp"}}]
|
||||||
(let [attrs (fs/make-permissions "rw-r--r--")
|
(let [attrs (fs/make-permissions "rw-r--r--")
|
||||||
path (fs/join default-tmp-dir (str prefix (uuid/next) suffix))
|
path (fs/join default-tmp-dir (str prefix (uuid/next) suffix))]
|
||||||
path (Files/createFile path attrs)]
|
(Files/createFile path attrs)))
|
||||||
(fs/delete-on-exit! path)
|
|
||||||
|
(defn tempfile
|
||||||
|
[& {:keys [min-age] :as opts}]
|
||||||
|
(let [path (tempfile* opts)]
|
||||||
(sp/offer! queue [path (some-> min-age ct/duration)])
|
(sp/offer! queue [path (some-> min-age ct/duration)])
|
||||||
path))
|
path))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user