🐛 Add validation and repair for files with nil in component :objects

This commit is contained in:
Pablo Alba 2023-11-17 09:33:37 +01:00 committed by Andrés Moya
parent 0eb66464ab
commit 6c1c780758
4 changed files with 53 additions and 9 deletions

View file

@ -271,11 +271,24 @@
(let [nearest-frame (cph/get-frame objects (:parent-id shape))
frame-id (or (:id nearest-frame) uuid/zero)]
(update objects (:id shape) assoc :frame-id frame-id))
objects)))]
objects)))]
(-> file-data
(update :pages-index update-vals fix-container)
(update :components update-vals fix-container))))]
(update :components update-vals fix-container))))
fix-component-nil-objects
(fn [file-data]
;; Ensure that objects of all components is not null
(letfn [(fix-component
[component]
(if (and (contains? component :objects) (nil? (:objects component)))
(if (:deleted component)
(assoc component :objects [])
(dissoc component :objects))
component))]
(-> file-data
(update :components update-vals fix-component))))]
(-> file-data
(fix-orphan-shapes)
@ -286,7 +299,8 @@
(fix-copies-of-detached)
(transform-to-frames)
(remap-frame-ids)
(fix-frame-ids))))
(fix-frame-ids)
(fix-component-nil-objects))))
(defn- migrate-components
"If there is any component in the file library, add a new 'Library