mirror of
https://github.com/penpot/penpot.git
synced 2026-11-10 03:50:33 +00:00
⚡ Don't send file data contents back from duplicate-file (#12911)
The client calls the duplicate-file command in two places, the dashboard and in the plugin API. In both places the :data is dropped via `(dissoc file :data)`, so the client never uses that field. However the file data takes a while to send over the wire and decode. When duplicating penpot-app there's a roughly 1s freeze whenever the response is returned from the server with the file data. We can avoid it by dropping the data from the response. I also did a quick check and neither the MCP server nor any public client of the API on GitHub seem to use the :data field. Co-authored-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
parent
fb7468c3f5
commit
3de7e62aa9
@ -106,10 +106,12 @@
|
||||
(db/exec-one! conn ["SET CONSTRAINTS ALL DEFERRED"])
|
||||
|
||||
(binding [bfc/*state* (volatile! {:index {file-id (uuid/next)}})]
|
||||
(duplicate-file (assoc cfg ::bfc/timestamp (ct/now))
|
||||
(-> params
|
||||
(assoc :profile-id profile-id)
|
||||
(assoc :reset-shared-flag true)))))))
|
||||
(-> (duplicate-file (assoc cfg ::bfc/timestamp (ct/now))
|
||||
(-> params
|
||||
(assoc :profile-id profile-id)
|
||||
(assoc :reset-shared-flag true)))
|
||||
;; Clients only need the metadata, don't send the full file contents.
|
||||
(dissoc :data))))))
|
||||
|
||||
;; --- COMMAND: Duplicate Project
|
||||
|
||||
|
||||
@ -167,11 +167,8 @@
|
||||
(t/is (= (:media-id item) (:media-id mobj)))
|
||||
(t/is (= (:media-id item) (:id sobject)))
|
||||
|
||||
;; Check if media correctly contains the new file-media-object id
|
||||
(t/is (contains? (get-in result [:data :media]) (:id item)))
|
||||
|
||||
;; And does not contains the old one
|
||||
(t/is (not (contains? (get-in result [:data :media]) (:id mobj)))))
|
||||
;; The response carries the file metadata only
|
||||
(t/is (not (contains? result :data))))
|
||||
|
||||
;; Check the total number of files
|
||||
(let [rows (th/db-query :file {:project-id (:id project)})]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user