mirror of
https://github.com/penpot/penpot.git
synced 2025-03-10 14:51:37 -05: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-schema! file))
|
||||
|
||||
(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 (if (contains? (:features file) "fdata/objects-map")
|
||||
(defn- persist-file!
|
||||
[{:keys [::db/conn] :as system} {:keys [id] :as file}]
|
||||
(let [file (if (contains? (:features file) "fdata/objects-map")
|
||||
(fdata/enable-objects-map file)
|
||||
file)
|
||||
|
||||
|
@ -1542,15 +1530,32 @@
|
|||
(let [file (fdata/enable-pointer-map file)]
|
||||
(fdata/persist-pointers! system id)
|
||||
file))
|
||||
file)]
|
||||
file)
|
||||
|
||||
;; Ensure all files has :data with id
|
||||
file (update file :data assoc :id id)]
|
||||
|
||||
(db/update! conn :file
|
||||
{:data (blob/encode (:data file))
|
||||
:features (db/create-array conn "text" (:features 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
|
||||
"SELECT f.id
|
||||
|
@ -1600,13 +1605,15 @@
|
|||
(when (string? label)
|
||||
(fsnap/take-file-snapshot! system {:file-id file-id
|
||||
: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
|
||||
{:op :migrate-file
|
||||
:name (:name file)
|
||||
:id (:id file)})
|
||||
|
||||
(process-file system file :validate? validate?)))))
|
||||
(persist-file! system file)))))
|
||||
|
||||
(catch Throwable cause
|
||||
(vreset! err true)
|
||||
|
|
Loading…
Add table
Reference in a new issue