0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 00:10:11 -05:00

🐛 Fix absorb libraries

This commit is contained in:
Andrés Moya 2023-03-23 16:32:00 +01:00
parent 96540af2b1
commit fe898315c3

View file

@ -201,6 +201,16 @@
::db/check-deleted? false})]
(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!
[conn file-id]
(doseq [[id item] @pmap/*tracked*]
@ -846,18 +856,23 @@
(let [library (db/get-by-id conn :file id)]
(when (:is-shared library)
(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})
(map :file-id)
(keep #(db/get-by-id conn :file % ::db/check-deleted? false))
(map decode-row)
(map pmg/migrate-file)
(run! (fn [{:keys [id data revn] :as file}]
(let [data (ctf/absorb-assets data ldata)]
(db/update! conn :file
{:revn (inc revn)
:data (blob/encode data)
:modified-at (dt/now)}
{:id id})))))))))
(binding [pmap/*tracked* (atom {})
pmap/*load-fn* (partial load-pointer conn id)]
(let [data (ctf/absorb-assets data ldata)]
(db/update! conn :file
{:revn (inc revn)
:data (blob/encode data)
:modified-at (dt/now)}
{:id id}))
(persist-pointers! conn id)))))))))
(s/def ::set-file-shared
(s/keys :req [::rpc/profile-id]