mirror of
https://github.com/penpot/penpot.git
synced 2025-05-18 18:06:10 +02:00
✨ Fix problem with garbage collection
This commit is contained in:
parent
c28c55bf0b
commit
dd8480cd87
3 changed files with 13 additions and 7 deletions
|
@ -13,6 +13,7 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.files.migrations :as pmg]
|
[app.common.files.migrations :as pmg]
|
||||||
[app.common.logging :as l]
|
[app.common.logging :as l]
|
||||||
|
[app.common.thumbnails :as thc]
|
||||||
[app.common.types.components-list :as ctkl]
|
[app.common.types.components-list :as ctkl]
|
||||||
[app.common.types.file :as ctf]
|
[app.common.types.file :as ctf]
|
||||||
[app.common.types.shape-tree :as ctt]
|
[app.common.types.shape-tree :as ctt]
|
||||||
|
@ -152,15 +153,19 @@
|
||||||
|
|
||||||
(defn- clean-file-object-thumbnails!
|
(defn- clean-file-object-thumbnails!
|
||||||
[{:keys [::db/conn ::sto/storage]} file-id data]
|
[{: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}
|
{:file-id file-id}
|
||||||
{:columns [:object-id]})
|
{:columns [:object-id]})
|
||||||
(into #{} (map :object-id)))
|
(into #{} (map :object-id)))
|
||||||
|
|
||||||
using (into #{}
|
using (into #{}
|
||||||
(mapcat (fn [{:keys [id objects]}]
|
(mapcat
|
||||||
|
(fn [{:keys [id objects]}]
|
||||||
(->> (ctt/get-frames objects)
|
(->> (ctt/get-frames objects)
|
||||||
(map #(str id (:id %))))))
|
(mapcat
|
||||||
|
#(vector
|
||||||
|
(thc/fmt-object-id file-id id (:id %) "frame")
|
||||||
|
(thc/fmt-object-id file-id id (:id %) "component"))))))
|
||||||
(vals (:pages-index data)))
|
(vals (:pages-index data)))
|
||||||
|
|
||||||
unused (set/difference stored using)]
|
unused (set/difference stored using)]
|
||||||
|
|
|
@ -713,7 +713,7 @@
|
||||||
(t/is (nil? (get-in result [:page :objects frame1-id :thumbnail])))
|
(t/is (nil? (get-in result [:page :objects frame1-id :thumbnail])))
|
||||||
(t/is (not= [] (get-in result [:page :objects frame1-id :shapes])))))
|
(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
|
;; insert object snapshot for known frame
|
||||||
(let [data {::th/type :upsert-file-object-thumbnail
|
(let [data {::th/type :upsert-file-object-thumbnail
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
|
|
||||||
(ns backend-tests.rpc-file-thumbnails-test
|
(ns backend-tests.rpc-file-thumbnails-test
|
||||||
(:require
|
(:require
|
||||||
[app.common.uuid :as uuid]
|
[app.common.thumbnails :as thc]
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.rpc :as-alias rpc]
|
[app.rpc :as-alias rpc]
|
||||||
|
@ -66,7 +67,7 @@
|
||||||
data2 {::th/type :create-file-object-thumbnail
|
data2 {::th/type :create-file-object-thumbnail
|
||||||
::rpc/profile-id (:id profile)
|
::rpc/profile-id (:id profile)
|
||||||
:file-id (:id file)
|
: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"
|
:media {:filename "sample.jpg"
|
||||||
:size 7923
|
:size 7923
|
||||||
:path (th/tempfile "backend_tests/test_files/sample2.jpg")
|
:path (th/tempfile "backend_tests/test_files/sample2.jpg")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue