diff --git a/backend/src/app/tasks/file_gc.clj b/backend/src/app/tasks/file_gc.clj index 93a86dd02..71cb00b1d 100644 --- a/backend/src/app/tasks/file_gc.clj +++ b/backend/src/app/tasks/file_gc.clj @@ -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)] diff --git a/backend/test/backend_tests/rpc_file_test.clj b/backend/test/backend_tests/rpc_file_test.clj index a842fa467..c4c2860fb 100644 --- a/backend/test/backend_tests/rpc_file_test.clj +++ b/backend/test/backend_tests/rpc_file_test.clj @@ -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 diff --git a/backend/test/backend_tests/rpc_file_thumbnails_test.clj b/backend/test/backend_tests/rpc_file_thumbnails_test.clj index c46a57d8c..e846e6bb0 100644 --- a/backend/test/backend_tests/rpc_file_thumbnails_test.clj +++ b/backend/test/backend_tests/rpc_file_thumbnails_test.clj @@ -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")