mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 00:40:30 -05:00
🐛 Fix absorb libraries
This commit is contained in:
parent
96540af2b1
commit
fe898315c3
1 changed files with 21 additions and 6 deletions
|
@ -201,6 +201,16 @@
|
||||||
::db/check-deleted? false})]
|
::db/check-deleted? false})]
|
||||||
(blob/decode (:content row))))
|
(blob/decode (:content row))))
|
||||||
|
|
||||||
|
(defn load-all-pointers!
|
||||||
|
[data]
|
||||||
|
(doseq [[_id page] (:pages-index data)]
|
||||||
|
(when (pmap/pointer-map? page)
|
||||||
|
(pmap/load! page)))
|
||||||
|
(doseq [[_id component] (:components data)]
|
||||||
|
(when (pmap/pointer-map? component)
|
||||||
|
(pmap/load! component)))
|
||||||
|
data)
|
||||||
|
|
||||||
(defn persist-pointers!
|
(defn persist-pointers!
|
||||||
[conn file-id]
|
[conn file-id]
|
||||||
(doseq [[id item] @pmap/*tracked*]
|
(doseq [[id item] @pmap/*tracked*]
|
||||||
|
@ -846,18 +856,23 @@
|
||||||
(let [library (db/get-by-id conn :file id)]
|
(let [library (db/get-by-id conn :file id)]
|
||||||
(when (:is-shared library)
|
(when (:is-shared library)
|
||||||
(let [ldata (-> library decode-row pmg/migrate-file :data)]
|
(let [ldata (-> library decode-row pmg/migrate-file :data)]
|
||||||
|
(binding [pmap/*load-fn* (partial load-pointer conn id)]
|
||||||
|
(load-all-pointers! ldata))
|
||||||
(->> (db/query conn :file-library-rel {:library-file-id id})
|
(->> (db/query conn :file-library-rel {:library-file-id id})
|
||||||
(map :file-id)
|
(map :file-id)
|
||||||
(keep #(db/get-by-id conn :file % ::db/check-deleted? false))
|
(keep #(db/get-by-id conn :file % ::db/check-deleted? false))
|
||||||
(map decode-row)
|
(map decode-row)
|
||||||
(map pmg/migrate-file)
|
(map pmg/migrate-file)
|
||||||
(run! (fn [{:keys [id data revn] :as file}]
|
(run! (fn [{:keys [id data revn] :as file}]
|
||||||
|
(binding [pmap/*tracked* (atom {})
|
||||||
|
pmap/*load-fn* (partial load-pointer conn id)]
|
||||||
(let [data (ctf/absorb-assets data ldata)]
|
(let [data (ctf/absorb-assets data ldata)]
|
||||||
(db/update! conn :file
|
(db/update! conn :file
|
||||||
{:revn (inc revn)
|
{:revn (inc revn)
|
||||||
:data (blob/encode data)
|
:data (blob/encode data)
|
||||||
:modified-at (dt/now)}
|
:modified-at (dt/now)}
|
||||||
{:id id})))))))))
|
{:id id}))
|
||||||
|
(persist-pointers! conn id)))))))))
|
||||||
|
|
||||||
(s/def ::set-file-shared
|
(s/def ::set-file-shared
|
||||||
(s/keys :req [::rpc/profile-id]
|
(s/keys :req [::rpc/profile-id]
|
||||||
|
|
Loading…
Reference in a new issue