⚡ 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:
Luke Lau 2026-11-10 00:23:39 +08:00 committed by GitHub
parent fb7468c3f5
commit 3de7e62aa9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 9 deletions

View File

@ -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

View File

@ -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)})]