From 3de7e62aa906835b113f501f1937d117bb340986 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Tue, 10 Nov 2026 00:23:39 +0800 Subject: [PATCH] :zap: 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 --- backend/src/app/rpc/commands/management.clj | 10 ++++++---- backend/test/backend_tests/rpc_management_test.clj | 7 ++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/backend/src/app/rpc/commands/management.clj b/backend/src/app/rpc/commands/management.clj index b0ac390b57..a71e81100c 100644 --- a/backend/src/app/rpc/commands/management.clj +++ b/backend/src/app/rpc/commands/management.clj @@ -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 diff --git a/backend/test/backend_tests/rpc_management_test.clj b/backend/test/backend_tests/rpc_management_test.clj index eec3aaabb9..ef353511c9 100644 --- a/backend/test/backend_tests/rpc_management_test.clj +++ b/backend/test/backend_tests/rpc_management_test.clj @@ -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)})]