From 86ad56797bd9c7ea21b302cc359ffb936b3f5d8f Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 13 Nov 2025 15:08:45 +0100 Subject: [PATCH] :sparkles: 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. --- backend/src/app/storage/tmp.clj | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/src/app/storage/tmp.clj b/backend/src/app/storage/tmp.clj index 4bbff4a72d..aa9f7de8dc 100644 --- a/backend/src/app/storage/tmp.clj +++ b/backend/src/app/storage/tmp.clj @@ -79,14 +79,17 @@ ;; API ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defn tempfile - [& {:keys [suffix prefix min-age] +(defn tempfile* + [& {:keys [suffix prefix] :or {prefix "penpot." suffix ".tmp"}}] (let [attrs (fs/make-permissions "rw-r--r--") - path (fs/join default-tmp-dir (str prefix (uuid/next) suffix)) - path (Files/createFile path attrs)] - (fs/delete-on-exit! path) + path (fs/join default-tmp-dir (str prefix (uuid/next) suffix))] + (Files/createFile path attrs))) + +(defn tempfile + [& {:keys [min-age] :as opts}] + (let [path (tempfile* opts)] (sp/offer! queue [path (some-> min-age ct/duration)]) path))