mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 21:09:00 -05:00
✨ Make retrieving fdata for thumbnail to no modify the file
This prevents that file to be considered opened just for creating the thumbnail for it.
This commit is contained in:
parent
ac20451ae7
commit
0ad2e8a0f2
1 changed files with 30 additions and 39 deletions
|
@ -10,6 +10,7 @@
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.features :as cfeat]
|
[app.common.features :as cfeat]
|
||||||
[app.common.files.helpers :as cfh]
|
[app.common.files.helpers :as cfh]
|
||||||
|
[app.common.files.migrations :as fmg]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.common.thumbnails :as thc]
|
[app.common.thumbnails :as thc]
|
||||||
|
@ -105,24 +106,12 @@
|
||||||
(letfn [;; function responsible on finding the frame marked to be
|
(letfn [;; function responsible on finding the frame marked to be
|
||||||
;; used as thumbnail; the returned frame always have
|
;; used as thumbnail; the returned frame always have
|
||||||
;; the :page-id set to the page that it belongs.
|
;; the :page-id set to the page that it belongs.
|
||||||
|
(get-thumbnail-frame [{:keys [data]}]
|
||||||
(get-thumbnail-frame [file]
|
|
||||||
;; NOTE: this is a hack for avoid perform blocking
|
|
||||||
;; operation inside the for loop, clojure lazy-seq uses
|
|
||||||
;; synchronized blocks that does not plays well with
|
|
||||||
;; virtual threads where all rpc methods calls are
|
|
||||||
;; dispatched, so we need to perform the load operation
|
|
||||||
;; first. This operation forces all pointer maps load into
|
|
||||||
;; the memory.
|
|
||||||
;;
|
|
||||||
;; FIXME: this is no longer true with clojure>=1.12
|
|
||||||
(let [{:keys [data]} (update file :data feat.fdata/process-pointers pmap/load!)]
|
|
||||||
;; Then proceed to find the frame set for thumbnail
|
|
||||||
(d/seek #(or (:use-for-thumbnail %)
|
(d/seek #(or (:use-for-thumbnail %)
|
||||||
(:use-for-thumbnail? %)) ; NOTE: backward comp (remove on v1.21)
|
(:use-for-thumbnail? %)) ; NOTE: backward comp (remove on v1.21)
|
||||||
(for [page (-> data :pages-index vals)
|
(for [page (-> data :pages-index vals)
|
||||||
frame (-> page :objects ctt/get-frames)]
|
frame (-> page :objects ctt/get-frames)]
|
||||||
(assoc frame :page-id (:id page))))))
|
(assoc frame :page-id (:id page)))))
|
||||||
|
|
||||||
;; function responsible to filter objects data structure of
|
;; function responsible to filter objects data structure of
|
||||||
;; all unneeded shapes if a concrete frame is provided. If no
|
;; all unneeded shapes if a concrete frame is provided. If no
|
||||||
|
@ -166,7 +155,6 @@
|
||||||
|
|
||||||
objects)))]
|
objects)))]
|
||||||
|
|
||||||
(binding [pmap/*load-fn* (partial feat.fdata/load-pointer cfg id)]
|
|
||||||
(let [frame (get-thumbnail-frame file)
|
(let [frame (get-thumbnail-frame file)
|
||||||
frame-id (:id frame)
|
frame-id (:id frame)
|
||||||
page-id (or (:page-id frame)
|
page-id (or (:page-id frame)
|
||||||
|
@ -189,7 +177,7 @@
|
||||||
;; Assoc the available thumbnails and prune not visible shapes
|
;; Assoc the available thumbnails and prune not visible shapes
|
||||||
;; for avoid transfer unnecessary data.
|
;; for avoid transfer unnecessary data.
|
||||||
:always
|
:always
|
||||||
(update :objects assoc-thumbnails page-id thumbs))))))
|
(update :objects assoc-thumbnails page-id thumbs)))))
|
||||||
|
|
||||||
(def ^:private
|
(def ^:private
|
||||||
schema:get-file-data-for-thumbnail
|
schema:get-file-data-for-thumbnail
|
||||||
|
@ -221,7 +209,10 @@
|
||||||
:profile-id profile-id
|
:profile-id profile-id
|
||||||
:file-id file-id)
|
:file-id file-id)
|
||||||
|
|
||||||
file (files/get-file cfg file-id)]
|
file (binding [pmap/*load-fn* (partial feat.fdata/load-pointer cfg file-id)]
|
||||||
|
(-> (files/get-file cfg file-id :migrate? false)
|
||||||
|
(update :data feat.fdata/process-pointers deref)
|
||||||
|
(fmg/migrate-file)))]
|
||||||
|
|
||||||
(-> (cfeat/get-team-enabled-features cf/flags team)
|
(-> (cfeat/get-team-enabled-features cf/flags team)
|
||||||
(cfeat/check-client-features! (:features params))
|
(cfeat/check-client-features! (:features params))
|
||||||
|
|
Loading…
Add table
Reference in a new issue