mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 20:01:39 +02:00
🐛 Fix incompatibility of binfile exportation with offload feature
This commit is contained in:
parent
5793c526c0
commit
f62aecb383
3 changed files with 44 additions and 13 deletions
|
@ -52,6 +52,15 @@
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(def file-attrs
|
||||||
|
#{:id
|
||||||
|
:name
|
||||||
|
:features
|
||||||
|
:project-id
|
||||||
|
:is-shared
|
||||||
|
:version
|
||||||
|
:data})
|
||||||
|
|
||||||
(def xf-map-id
|
(def xf-map-id
|
||||||
(map :id))
|
(map :id))
|
||||||
|
|
||||||
|
@ -129,10 +138,11 @@
|
||||||
(binding [pmap/*load-fn* (partial feat.fdata/load-pointer cfg file-id)]
|
(binding [pmap/*load-fn* (partial feat.fdata/load-pointer cfg file-id)]
|
||||||
(when-let [file (db/get* conn :file {:id file-id}
|
(when-let [file (db/get* conn :file {:id file-id}
|
||||||
{::db/remove-deleted false})]
|
{::db/remove-deleted false})]
|
||||||
|
(let [file (feat.fdata/resolve-file-data cfg file)]
|
||||||
(-> file
|
(-> file
|
||||||
(decode-row)
|
(decode-row)
|
||||||
(update :data feat.fdata/process-pointers deref)
|
(update :data feat.fdata/process-pointers deref)
|
||||||
(update :data feat.fdata/process-objects (partial into {}))))))))
|
(update :data feat.fdata/process-objects (partial into {})))))))))
|
||||||
|
|
||||||
(defn clean-file-features
|
(defn clean-file-features
|
||||||
[file]
|
[file]
|
||||||
|
|
|
@ -56,7 +56,6 @@
|
||||||
[:map
|
[:map
|
||||||
[:id ::sm/uuid]
|
[:id ::sm/uuid]
|
||||||
[:name :string]
|
[:name :string]
|
||||||
[:project-id ::sm/uuid]
|
|
||||||
[:features ::cfeat/features]]]]
|
[:features ::cfeat/features]]]]
|
||||||
|
|
||||||
[:relations {:optional true}
|
[:relations {:optional true}
|
||||||
|
@ -79,10 +78,15 @@
|
||||||
[:tag :string]
|
[:tag :string]
|
||||||
[:media-id ::sm/uuid]])
|
[:media-id ::sm/uuid]])
|
||||||
|
|
||||||
|
(def ^:private schema:file
|
||||||
|
[:merge
|
||||||
|
ctf/schema:file
|
||||||
|
[:map [:options {:optional true} ctf/schema:options]]])
|
||||||
|
|
||||||
;; --- ENCODERS
|
;; --- ENCODERS
|
||||||
|
|
||||||
(def encode-file
|
(def encode-file
|
||||||
(sm/encoder ::ctf/file sm/json-transformer))
|
(sm/encoder schema:file sm/json-transformer))
|
||||||
|
|
||||||
(def encode-page
|
(def encode-page
|
||||||
(sm/encoder ::ctp/page sm/json-transformer))
|
(sm/encoder ::ctp/page sm/json-transformer))
|
||||||
|
@ -126,7 +130,7 @@
|
||||||
(sm/decoder ::ctcl/color sm/json-transformer))
|
(sm/decoder ::ctcl/color sm/json-transformer))
|
||||||
|
|
||||||
(def decode-file
|
(def decode-file
|
||||||
(sm/decoder ::ctf/file sm/json-transformer))
|
(sm/decoder schema:file sm/json-transformer))
|
||||||
|
|
||||||
(def decode-page
|
(def decode-page
|
||||||
(sm/decoder ::ctp/page sm/json-transformer))
|
(sm/decoder ::ctp/page sm/json-transformer))
|
||||||
|
@ -198,8 +202,9 @@
|
||||||
(throw (IllegalArgumentException.
|
(throw (IllegalArgumentException.
|
||||||
"the `include-libraries` and `embed-assets` are mutally excluding options")))
|
"the `include-libraries` and `embed-assets` are mutally excluding options")))
|
||||||
|
|
||||||
(let [detach? (and (not embed-assets) (not include-libraries))]
|
(let [detach? (and (not embed-assets) (not include-libraries))
|
||||||
(cond-> (bfc/get-file cfg file-id)
|
file (bfc/get-file cfg file-id)]
|
||||||
|
(cond-> file
|
||||||
detach?
|
detach?
|
||||||
(-> (ctf/detach-external-references file-id)
|
(-> (ctf/detach-external-references file-id)
|
||||||
(dissoc :libraries))
|
(dissoc :libraries))
|
||||||
|
@ -263,13 +268,16 @@
|
||||||
|
|
||||||
(vswap! bfc/*state* update :files assoc file-id
|
(vswap! bfc/*state* update :files assoc file-id
|
||||||
{:id file-id
|
{:id file-id
|
||||||
:project-id (:project-id file)
|
|
||||||
:name (:name file)
|
:name (:name file)
|
||||||
:features (:features file)})
|
:features (:features file)})
|
||||||
|
|
||||||
(let [file (cond-> (dissoc file :data)
|
(let [file (cond-> (select-keys file bfc/file-attrs)
|
||||||
(:options data)
|
(:options data)
|
||||||
(assoc :options (:options data))
|
(assoc :options (:options data))
|
||||||
|
|
||||||
|
:always
|
||||||
|
(dissoc :data)
|
||||||
|
|
||||||
:always
|
:always
|
||||||
(encode-file))
|
(encode-file))
|
||||||
path (str "files/" file-id ".json")]
|
path (str "files/" file-id ".json")]
|
||||||
|
@ -623,7 +631,7 @@
|
||||||
(not-empty)))
|
(not-empty)))
|
||||||
|
|
||||||
(defn- read-file-data
|
(defn- read-file-data
|
||||||
[{:keys [] :as cfg}]
|
[cfg]
|
||||||
(let [colors (read-file-colors cfg)
|
(let [colors (read-file-colors cfg)
|
||||||
typographies (read-file-typographies cfg)
|
typographies (read-file-typographies cfg)
|
||||||
components (read-file-components cfg)
|
components (read-file-components cfg)
|
||||||
|
@ -678,7 +686,7 @@
|
||||||
(cond-> (:options file)
|
(cond-> (:options file)
|
||||||
(assoc :options (:options file))))
|
(assoc :options (:options file))))
|
||||||
|
|
||||||
file (-> file
|
file (-> (select-keys file bfc/file-attrs)
|
||||||
(assoc :id file-id')
|
(assoc :id file-id')
|
||||||
(assoc :data data)
|
(assoc :data data)
|
||||||
(assoc :name file-name)
|
(assoc :name file-name)
|
||||||
|
|
|
@ -63,10 +63,15 @@
|
||||||
(def schema:pages-index
|
(def schema:pages-index
|
||||||
[:map-of {:gen/max 5} ::sm/uuid ::ctp/page])
|
[:map-of {:gen/max 5} ::sm/uuid ::ctp/page])
|
||||||
|
|
||||||
|
(def schema:options
|
||||||
|
[:map {:title "FileOptions"}
|
||||||
|
[:components-v2 {:optional true} ::sm/boolean]])
|
||||||
|
|
||||||
(def schema:data
|
(def schema:data
|
||||||
[:map {:title "FileData"}
|
[:map {:title "FileData"}
|
||||||
[:pages [:vector ::sm/uuid]]
|
[:pages [:vector ::sm/uuid]]
|
||||||
[:pages-index schema:pages-index]
|
[:pages-index schema:pages-index]
|
||||||
|
[:options {:optional true} schema:options]
|
||||||
[:colors {:optional true} schema:colors]
|
[:colors {:optional true} schema:colors]
|
||||||
[:components {:optional true} schema:components]
|
[:components {:optional true} schema:components]
|
||||||
[:typographies {:optional true} schema:typographies]
|
[:typographies {:optional true} schema:typographies]
|
||||||
|
@ -78,7 +83,15 @@
|
||||||
because sometimes we want to validate file without the data."
|
because sometimes we want to validate file without the data."
|
||||||
[:map {:title "file"}
|
[:map {:title "file"}
|
||||||
[:id ::sm/uuid]
|
[:id ::sm/uuid]
|
||||||
|
[:revn {:optional true} :int]
|
||||||
|
[:vern {:optional true} :int]
|
||||||
|
[:created-at {:optional true} ::sm/inst]
|
||||||
|
[:modified-at {:optional true} ::sm/inst]
|
||||||
|
[:deleted-at {:optional true} ::sm/inst]
|
||||||
|
[:project-id {:optional true} ::sm/uuid]
|
||||||
|
[:is-shared {:optional true} ::sm/boolean]
|
||||||
[:data {:optional true} schema:data]
|
[:data {:optional true} schema:data]
|
||||||
|
[:version :int]
|
||||||
[:features ::cfeat/features]])
|
[:features ::cfeat/features]])
|
||||||
|
|
||||||
(sm/register! ::data schema:data)
|
(sm/register! ::data schema:data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue