0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 00:10:11 -05:00

Fix problem with garbage collection

This commit is contained in:
alonso.torres 2023-10-31 12:21:02 +01:00 committed by Alonso Torres
parent c28c55bf0b
commit dd8480cd87
3 changed files with 13 additions and 7 deletions

View file

@ -13,6 +13,7 @@
[app.common.data :as d]
[app.common.files.migrations :as pmg]
[app.common.logging :as l]
[app.common.thumbnails :as thc]
[app.common.types.components-list :as ctkl]
[app.common.types.file :as ctf]
[app.common.types.shape-tree :as ctt]
@ -152,15 +153,19 @@
(defn- clean-file-object-thumbnails!
[{:keys [::db/conn ::sto/storage]} file-id data]
(let [stored (->> (db/query conn :file-object-thumbnail
(let [stored (->> (db/query conn :file_object_thumbnail
{:file-id file-id}
{:columns [:object-id]})
(into #{} (map :object-id)))
using (into #{}
(mapcat (fn [{:keys [id objects]}]
(->> (ctt/get-frames objects)
(map #(str id (:id %))))))
(mapcat
(fn [{:keys [id objects]}]
(->> (ctt/get-frames objects)
(mapcat
#(vector
(thc/fmt-object-id file-id id (:id %) "frame")
(thc/fmt-object-id file-id id (:id %) "component"))))))
(vals (:pages-index data)))
unused (set/difference stored using)]

View file

@ -713,7 +713,7 @@
(t/is (nil? (get-in result [:page :objects frame1-id :thumbnail])))
(t/is (not= [] (get-in result [:page :objects frame1-id :shapes])))))
#_(t/testing "TASK :file-gc"
(t/testing "TASK :file-gc"
;; insert object snapshot for known frame
(let [data {::th/type :upsert-file-object-thumbnail

View file

@ -6,8 +6,9 @@
(ns backend-tests.rpc-file-thumbnails-test
(:require
[app.common.uuid :as uuid]
[app.common.thumbnails :as thc]
[app.common.types.shape :as cts]
[app.common.uuid :as uuid]
[app.config :as cf]
[app.db :as db]
[app.rpc :as-alias rpc]
@ -66,7 +67,7 @@
data2 {::th/type :create-file-object-thumbnail
::rpc/profile-id (:id profile)
:file-id (:id file)
:object-id (str page-id shid)
:object-id (thc/fmt-object-id (:id file) page-id shid "frame")
:media {:filename "sample.jpg"
:size 7923
:path (th/tempfile "backend_tests/test_files/sample2.jpg")