🐛 Add migration for clearing :objects nil from components

on the local library
This commit is contained in:
Andrey Antukh 2025-10-14 17:14:25 +02:00
parent d9714e6d6e
commit 1aa449ba49

View File

@ -234,7 +234,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)
@ -288,7 +288,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)
@ -386,21 +388,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))))
@ -1653,6 +1654,18 @@
(update :pages-index d/update-vals update-container)
(d/update-when :components d/update-vals update-container))))
(defmethod migrate-data "0017-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.
(letfn [(update-container [container]
(d/without-nils container))]
(d/update-when data :components d/update-vals update-container)))
(def available-migrations
(into (d/ordered-set)
["legacy-2"
@ -1724,4 +1737,5 @@
"0013-fix-component-path"
"0014-fix-tokens-lib-duplicate-ids"
"0015-clear-invalid-strokes-and-fills"
"0016-clear-pages-and-shapes"]))
"0016-clear-pages-and-shapes"
"0017-clear-components-nil-objects"]))