From 47d28758d771ec42a2610d83def4d5b22cd348d9 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 15 Nov 2024 15:54:57 +0100 Subject: [PATCH] :sparkles: Clean frontend and backend features on exportation --- backend/src/app/binfile/common.clj | 10 ++++++++++ backend/src/app/binfile/v1.clj | 12 +----------- backend/src/app/binfile/v3.clj | 12 +++++++++--- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/backend/src/app/binfile/common.clj b/backend/src/app/binfile/common.clj index 8808aa4f6..739b272e1 100644 --- a/backend/src/app/binfile/common.clj +++ b/backend/src/app/binfile/common.clj @@ -134,6 +134,16 @@ (update :data feat.fdata/process-pointers deref) (update :data feat.fdata/process-objects (partial into {})))))))) +(defn clean-file-features + [file] + (update file :features (fn [features] + (if (set? features) + (-> features + (cfeat/migrate-legacy-features) + (set/difference cfeat/frontend-only-features) + (set/difference cfeat/backend-only-features)) + #{})))) + (defn get-project [cfg project-id] (db/get cfg :project {:id project-id})) diff --git a/backend/src/app/binfile/v1.clj b/backend/src/app/binfile/v1.clj index 086d296a2..244720d2b 100644 --- a/backend/src/app/binfile/v1.clj +++ b/backend/src/app/binfile/v1.clj @@ -508,16 +508,6 @@ (update :object-id #(str/replace-first % #"^(.*?)/" (str file-id "/"))))) thumbnails)) -(defn- clean-features - [file] - (update file :features (fn [features] - (if (set? features) - (-> features - (cfeat/migrate-legacy-features) - (set/difference cfeat/frontend-only-features) - (set/difference cfeat/backend-only-features)) - #{})))) - (defmethod read-section :v1/files [{:keys [::db/conn ::input ::project-id ::bfc/overwrite ::name] :as system}] @@ -528,7 +518,7 @@ file-id (:id file) file-id' (bfc/lookup-index file-id) - file (clean-features file) + file (bfc/clean-file-features file) thumbnails (:thumbnails file)] (when (not= file-id expected-file-id) diff --git a/backend/src/app/binfile/v3.clj b/backend/src/app/binfile/v3.clj index 4c1f8e205..7980c21df 100644 --- a/backend/src/app/binfile/v3.clj +++ b/backend/src/app/binfile/v3.clj @@ -12,6 +12,7 @@ [app.common.data :as d] [app.common.data.macros :as dm] [app.common.exceptions :as ex] + [app.common.features :as cfeat] [app.common.json :as json] [app.common.logging :as l] [app.common.schema :as sm] @@ -55,7 +56,8 @@ [:map [:id ::sm/uuid] [:name :string] - [:project-id ::sm/uuid]]]] + [:project-id ::sm/uuid] + [:features ::cfeat/features]]]] [:relations {:optional true} [:vector @@ -203,7 +205,10 @@ (dissoc :libraries)) embed-assets - (update :data #(bfc/embed-assets cfg % file-id))))) + (update :data #(bfc/embed-assets cfg % file-id)) + + :always + (bfc/clean-file-features)))) (defn- resolve-extension [mtype] @@ -259,7 +264,8 @@ (vswap! bfc/*state* update :files assoc file-id {:id file-id :project-id (:project-id file) - :name (:name file)}) + :name (:name file) + :features (:features file)}) (let [file (cond-> (dissoc file :data) (:options data)