From 239a6803bfc8ac4cb10ed096baaa19f4615a9ee8 Mon Sep 17 00:00:00 2001 From: Sergei Garin Date: Thu, 10 Oct 2024 17:51:59 +0300 Subject: [PATCH] Fix updating conflicting project (#11111) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes a bug, when uploading a duplicate project to local backend threw a crash on windows. https://github.com/user-attachments/assets/fe1bd7a7-d840-4bb1-b3f6-e0beec70fcd4 I found a bug when we upload a project to a remote backend, it throws a 500 error. Notified @PabloBuchu about that. Also, @hubertp proved that the ProjectManager always duplicates a project no matter which option we choose(either "update" or "renameā€œ). So I removed the "update" button if we upload a project locally --- app/dashboard/src/layouts/AssetsTable.tsx | 10 ++-------- app/dashboard/src/modals/DuplicateAssetsModal.tsx | 3 +++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/dashboard/src/layouts/AssetsTable.tsx b/app/dashboard/src/layouts/AssetsTable.tsx index 90e923b7f30..d26bdf478cb 100644 --- a/app/dashboard/src/layouts/AssetsTable.tsx +++ b/app/dashboard/src/layouts/AssetsTable.tsx @@ -1770,7 +1770,7 @@ export default function AssetsTable(props: AssetsTableProps) { addIdToSelection(projectId) await getProjectDetailsMutation - .mutateAsync([projectId, asset.parentId, file.name]) + .mutateAsync([projectId, asset.parentId, asset.title]) .catch((error) => { deleteAsset(projectId) toastAndLog('uploadProjectError', error) @@ -1887,13 +1887,7 @@ export default function AssetsTable(props: AssetsTableProps) { const asset = isUpdating ? conflict.current : conflict.new - fileMap.set( - asset.id, - new File([conflict.file], asset.title, { - type: conflict.file.type, - lastModified: conflict.file.lastModified, - }), - ) + fileMap.set(asset.id, conflict.file) insertAssets([asset], event.parentId) void doUploadFile(asset, isUpdating ? 'update' : 'new') diff --git a/app/dashboard/src/modals/DuplicateAssetsModal.tsx b/app/dashboard/src/modals/DuplicateAssetsModal.tsx index a1778b722c4..a6a6ca9cc3f 100644 --- a/app/dashboard/src/modals/DuplicateAssetsModal.tsx +++ b/app/dashboard/src/modals/DuplicateAssetsModal.tsx @@ -214,6 +214,7 @@ export default function DuplicateAssetsModal(props: DuplicateAssetsModalProps) { > {getText('update')} + { @@ -252,6 +253,7 @@ export default function DuplicateAssetsModal(props: DuplicateAssetsModalProps) { : getText('andOtherProjects', otherProjectsCount)} )} + {count === 1 ? getText('update') : getText('updateAll')} + {