mirror of
https://github.com/penpot/penpot.git
synced 2025-05-01 04:36:20 +02:00
Merge pull request #6175 from penpot/niwinz-develop-binfile-path-fix
🐛 Fix binfile-v3 importation related to bool shape normalization
This commit is contained in:
commit
2aa756af38
1 changed files with 39 additions and 17 deletions
|
@ -592,19 +592,6 @@
|
||||||
{})
|
{})
|
||||||
(not-empty)))
|
(not-empty)))
|
||||||
|
|
||||||
(defn- read-file-components
|
|
||||||
[{:keys [::bfc/input ::file-id ::entries]}]
|
|
||||||
(->> (keep (match-component-entry-fn file-id) entries)
|
|
||||||
(reduce (fn [result {:keys [id entry]}]
|
|
||||||
(let [object (->> (read-entry input entry)
|
|
||||||
(decode-component)
|
|
||||||
(validate-component))]
|
|
||||||
(if (= id (:id object))
|
|
||||||
(assoc result id object)
|
|
||||||
result)))
|
|
||||||
{})
|
|
||||||
(not-empty)))
|
|
||||||
|
|
||||||
(defn- read-file-typographies
|
(defn- read-file-typographies
|
||||||
[{:keys [::bfc/input ::file-id ::entries]}]
|
[{:keys [::bfc/input ::file-id ::entries]}]
|
||||||
(->> (keep (match-typography-entry-fn file-id) entries)
|
(->> (keep (match-typography-entry-fn file-id) entries)
|
||||||
|
@ -625,13 +612,49 @@
|
||||||
(decode-tokens-lib)
|
(decode-tokens-lib)
|
||||||
(validate-tokens-lib))))
|
(validate-tokens-lib))))
|
||||||
|
|
||||||
|
(defn- pre-decode-migrate-shape
|
||||||
|
"Applies a pre-decode phase migration to the shape"
|
||||||
|
[shape]
|
||||||
|
(if (= "bool" (:type shape))
|
||||||
|
(if-let [content (get shape :bool-content)]
|
||||||
|
(-> shape
|
||||||
|
(assoc :content content)
|
||||||
|
(dissoc :bool-content))
|
||||||
|
shape)
|
||||||
|
shape))
|
||||||
|
|
||||||
|
(defn- pre-decode-migrate-component
|
||||||
|
"Applies a pre-decode phase migration to component"
|
||||||
|
[component]
|
||||||
|
(d/update-when component :objects
|
||||||
|
(fn [objects]
|
||||||
|
(reduce-kv (fn [objects id shape]
|
||||||
|
(assoc objects id (pre-decode-migrate-shape shape)))
|
||||||
|
objects
|
||||||
|
objects))))
|
||||||
|
|
||||||
|
(defn- read-file-components
|
||||||
|
[{:keys [::bfc/input ::file-id ::entries]}]
|
||||||
|
(->> (keep (match-component-entry-fn file-id) entries)
|
||||||
|
(reduce (fn [result {:keys [id entry]}]
|
||||||
|
(let [object (->> (read-entry input entry)
|
||||||
|
(pre-decode-migrate-component)
|
||||||
|
(decode-component)
|
||||||
|
(validate-component))]
|
||||||
|
(if (= id (:id object))
|
||||||
|
(assoc result id object)
|
||||||
|
result)))
|
||||||
|
{})
|
||||||
|
(not-empty)))
|
||||||
|
|
||||||
(defn- read-file-shapes
|
(defn- read-file-shapes
|
||||||
[{:keys [::bfc/input ::file-id ::page-id ::entries] :as cfg}]
|
[{:keys [::bfc/input ::file-id ::page-id ::entries] :as cfg}]
|
||||||
(->> (keep (match-shape-entry-fn file-id page-id) entries)
|
(->> (keep (match-shape-entry-fn file-id page-id) entries)
|
||||||
(reduce (fn [result {:keys [id entry]}]
|
(reduce (fn [result {:keys [id entry]}]
|
||||||
(let [object (->> (read-entry input entry)
|
(let [object (-> (read-entry input entry)
|
||||||
(decode-shape)
|
(pre-decode-migrate-shape)
|
||||||
(validate-shape))]
|
(decode-shape)
|
||||||
|
(validate-shape))]
|
||||||
(if (= id (:id object))
|
(if (= id (:id object))
|
||||||
(assoc result id object)
|
(assoc result id object)
|
||||||
result)))
|
result)))
|
||||||
|
@ -735,7 +758,6 @@
|
||||||
(dissoc :options)
|
(dissoc :options)
|
||||||
(bfc/process-file))]
|
(bfc/process-file))]
|
||||||
|
|
||||||
|
|
||||||
(bfm/register-pending-migrations! cfg file)
|
(bfm/register-pending-migrations! cfg file)
|
||||||
(bfc/save-file! cfg file ::db/return-keys false)
|
(bfc/save-file! cfg file ::db/return-keys false)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue