mirror of https://github.com/penpot/penpot.git
🐛 Add migration for clearing :objects nil from components
on the local library
This commit is contained in:
parent
17376dfa3f
commit
c9dcc8a4ee
|
|
@ -231,7 +231,7 @@
|
|||
shape))
|
||||
|
||||
(update-container [container]
|
||||
(update container :objects d/update-vals fix-line-paths))]
|
||||
(d/update-when container :objects d/update-vals fix-line-paths))]
|
||||
|
||||
(-> data
|
||||
(update :pages-index d/update-vals update-container)
|
||||
|
|
@ -285,7 +285,9 @@
|
|||
(let [[deleted objects] (clean-objects objects)]
|
||||
(if (and (pos? deleted) (< n 1000))
|
||||
(recur (inc n) objects)
|
||||
(assoc container :objects objects)))))]
|
||||
(-> container
|
||||
(assoc :objects objects)
|
||||
(d/without-nils))))))]
|
||||
|
||||
(-> data
|
||||
(update :pages-index d/update-vals clean-container)
|
||||
|
|
@ -383,21 +385,20 @@
|
|||
(dissoc :fill-color :fill-opacity))))
|
||||
|
||||
(update-container [container]
|
||||
(if (contains? container :objects)
|
||||
(loop [objects (:objects container)
|
||||
shapes (->> (vals objects)
|
||||
(filter cfh/image-shape?))]
|
||||
(if-let [shape (first shapes)]
|
||||
(let [{:keys [id frame-id] :as shape'} (process-shape shape)]
|
||||
(if (identical? shape shape')
|
||||
(recur objects (rest shapes))
|
||||
(recur (-> objects
|
||||
(assoc id shape')
|
||||
(d/update-when frame-id dissoc :thumbnail))
|
||||
(rest shapes))))
|
||||
(assoc container :objects objects)))
|
||||
container))]
|
||||
|
||||
(loop [objects (:objects container)
|
||||
shapes (->> (vals objects)
|
||||
(filter cfh/image-shape?))]
|
||||
(if-let [shape (first shapes)]
|
||||
(let [{:keys [id frame-id] :as shape'} (process-shape shape)]
|
||||
(if (identical? shape shape')
|
||||
(recur objects (rest shapes))
|
||||
(recur (-> objects
|
||||
(assoc id shape')
|
||||
(d/update-when frame-id dissoc :thumbnail))
|
||||
(rest shapes))))
|
||||
(-> container
|
||||
(assoc :objects objects)
|
||||
(d/without-nils)))))]
|
||||
(-> data
|
||||
(update :pages-index d/update-vals update-container)
|
||||
(d/update-when :components d/update-vals update-container))))
|
||||
|
|
@ -1607,6 +1608,14 @@
|
|||
(update :pages-index d/update-vals update-container)
|
||||
(d/update-when :components d/update-vals update-container))))
|
||||
|
||||
(defmethod migrate-data "0014-clear-components-nil-objects"
|
||||
[data _]
|
||||
;; Because of a bug in migrations, several files have migrations
|
||||
;; applied in an incorrect order and because of other bug on old
|
||||
;; migrations, some files have components with `:objects` with `nil`
|
||||
;; as value; this migration fixes it.
|
||||
(d/update-when data :components d/update-vals d/without-nils))
|
||||
|
||||
(def available-migrations
|
||||
(into (d/ordered-set)
|
||||
["legacy-2"
|
||||
|
|
@ -1675,4 +1684,5 @@
|
|||
"0010-fix-swap-slots-pointing-non-existent-shapes"
|
||||
"0011-fix-invalid-text-touched-flags"
|
||||
"0012-fix-position-data"
|
||||
"0013-clear-invalid-strokes-and-fills"]))
|
||||
"0013-clear-invalid-strokes-and-fills"
|
||||
"0014-clear-components-nil-objects"]))
|
||||
|
|
|
|||
Loading…
Reference in New Issue