mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 01:06:13 +02:00
✨ Ensure id prop on :data on components-v2 migration
This commit is contained in:
parent
6fd30d50f4
commit
9649878fd8
1 changed files with 27 additions and 20 deletions
|
@ -1519,21 +1519,9 @@
|
||||||
(cfv/validate-file! file libs)
|
(cfv/validate-file! file libs)
|
||||||
(cfv/validate-file-schema! file))
|
(cfv/validate-file-schema! file))
|
||||||
|
|
||||||
(defn- process-file
|
(defn- persist-file!
|
||||||
[{:keys [::db/conn] :as system} {:keys [id] :as file} & {:keys [validate?]}]
|
[{:keys [::db/conn] :as system} {:keys [id] :as file}]
|
||||||
(let [libs (->> (files/get-file-libraries conn id)
|
(let [file (if (contains? (:features file) "fdata/objects-map")
|
||||||
(into [file] (comp (map :id)
|
|
||||||
(map (partial get-file system))))
|
|
||||||
(d/index-by :id))
|
|
||||||
|
|
||||||
file (-> file
|
|
||||||
(update :data migrate-fdata libs)
|
|
||||||
(update :features conj "components/v2"))
|
|
||||||
|
|
||||||
_ (when validate?
|
|
||||||
(validate-file! file libs))
|
|
||||||
|
|
||||||
file (if (contains? (:features file) "fdata/objects-map")
|
|
||||||
(fdata/enable-objects-map file)
|
(fdata/enable-objects-map file)
|
||||||
file)
|
file)
|
||||||
|
|
||||||
|
@ -1542,15 +1530,32 @@
|
||||||
(let [file (fdata/enable-pointer-map file)]
|
(let [file (fdata/enable-pointer-map file)]
|
||||||
(fdata/persist-pointers! system id)
|
(fdata/persist-pointers! system id)
|
||||||
file))
|
file))
|
||||||
file)]
|
file)
|
||||||
|
|
||||||
|
;; Ensure all files has :data with id
|
||||||
|
file (update file :data assoc :id id)]
|
||||||
|
|
||||||
(db/update! conn :file
|
(db/update! conn :file
|
||||||
{:data (blob/encode (:data file))
|
{:data (blob/encode (:data file))
|
||||||
:features (db/create-array conn "text" (:features file))
|
:features (db/create-array conn "text" (:features file))
|
||||||
:revn (:revn file)}
|
:revn (:revn file)}
|
||||||
{:id (:id file)})
|
{:id (:id file)})))
|
||||||
|
|
||||||
(dissoc file :data)))
|
(defn- process-file!
|
||||||
|
[{:keys [::db/conn] :as system} {:keys [id] :as file} & {:keys [validate?]}]
|
||||||
|
(let [libs (->> (files/get-file-libraries conn id)
|
||||||
|
(into [file] (comp (map :id)
|
||||||
|
(map (partial get-file system))))
|
||||||
|
(d/index-by :id))
|
||||||
|
|
||||||
|
file (-> file
|
||||||
|
(update :data migrate-fdata libs)
|
||||||
|
(update :features conj "components/v2"))]
|
||||||
|
|
||||||
|
(when validate?
|
||||||
|
(validate-file! file libs))
|
||||||
|
|
||||||
|
file))
|
||||||
|
|
||||||
(def ^:private sql:get-and-lock-team-files
|
(def ^:private sql:get-and-lock-team-files
|
||||||
"SELECT f.id
|
"SELECT f.id
|
||||||
|
@ -1600,13 +1605,15 @@
|
||||||
(when (string? label)
|
(when (string? label)
|
||||||
(fsnap/take-file-snapshot! system {:file-id file-id
|
(fsnap/take-file-snapshot! system {:file-id file-id
|
||||||
:label (str "migration/" label)}))
|
:label (str "migration/" label)}))
|
||||||
(let [file (get-file system file-id)]
|
(let [file (get-file system file-id)
|
||||||
|
file (process-file! system file :validate? validate?)]
|
||||||
|
|
||||||
(events/tap :progress
|
(events/tap :progress
|
||||||
{:op :migrate-file
|
{:op :migrate-file
|
||||||
:name (:name file)
|
:name (:name file)
|
||||||
:id (:id file)})
|
:id (:id file)})
|
||||||
|
|
||||||
(process-file system file :validate? validate?)))))
|
(persist-file! system file)))))
|
||||||
|
|
||||||
(catch Throwable cause
|
(catch Throwable cause
|
||||||
(vreset! err true)
|
(vreset! err true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue