From daec51bb7d3fe72dbb371259ab1a13e9f15d9b59 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 29 Nov 2023 14:48:44 +0100 Subject: [PATCH] :sparkles: Add feature naming migration on file importation --- backend/src/app/rpc/commands/binfile.clj | 1 + common/src/app/common/features.cljc | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/backend/src/app/rpc/commands/binfile.clj b/backend/src/app/rpc/commands/binfile.clj index f45903c79..614a138f9 100644 --- a/backend/src/app/rpc/commands/binfile.clj +++ b/backend/src/app/rpc/commands/binfile.clj @@ -719,6 +719,7 @@ file-id' (lookup-index file-id) thumbnails (:thumbnails file) + file (update file :features cfeat/migrate-legacy-features) features (-> enabled-features (set/difference cfeat/frontend-only-features) diff --git a/common/src/app/common/features.cljc b/common/src/app/common/features.cljc index e0b19a156..fc4bcab22 100644 --- a/common/src/app/common/features.cljc +++ b/common/src/app/common/features.cljc @@ -97,6 +97,24 @@ :feature-fdata-pointer-map "fdata/pointer-map" nil)) +(defn migrate-legacy-features + "A helper that translates old feature names to new names" + [features] + (cond-> (or features #{}) + (contains? features "storage/pointer-map") + (-> (conj "fdata/pointer-map") + (disj "storage/pointer-map")) + + (contains? features "storage/objects-map") + (-> (conj "fdata/objects-map") + (disj "storage/objects-map")) + + (or (contains? features "internal/geom-record") + (contains? features "internal/shape-record")) + (-> (conj "fdata/shape-data-type") + (disj "internal/geom-record") + (disj "internal/shape-record")))) + (def xf-supported-features (filter (partial contains? supported-features)))