From fefec2c1bfe565a53c63a0ecc7b3348ddd2c6ef1 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Fri, 26 Jan 2024 09:28:20 +0000 Subject: [PATCH] Improve handling of upload to deleted folder (#16738) GitOrigin-RevId: 2ad2890f8fe51f3c7c7a8ac0834059ea9cb0557b --- .../app/src/Features/Project/ProjectEntityUpdateHandler.js | 6 ++++++ .../app/src/Features/Uploads/ProjectUploadController.js | 5 +++++ services/web/frontend/extracted-translations.json | 1 + .../components/file-tree-create/error-message.jsx | 7 +++++++ services/web/locales/en.json | 1 + 5 files changed, 20 insertions(+) diff --git a/services/web/app/src/Features/Project/ProjectEntityUpdateHandler.js b/services/web/app/src/Features/Project/ProjectEntityUpdateHandler.js index ab63f6a0d6..e91f59fbad 100644 --- a/services/web/app/src/Features/Project/ProjectEntityUpdateHandler.js +++ b/services/web/app/src/Features/Project/ProjectEntityUpdateHandler.js @@ -653,6 +653,9 @@ const ProjectEntityUpdateHandler = { { project_id: projectId, element_id: folderId, type: 'folder' }, (error, folder, folderPath) => { if (error != null) { + if (error instanceof Errors.NotFoundError && folder == null) { + return callback(new Error('folder_not_found')) + } return callback(error) } if (folder == null) { @@ -842,6 +845,9 @@ const ProjectEntityUpdateHandler = { { project_id: projectId, element_id: folderId, type: 'folder' }, (error, folder) => { if (error != null) { + if (error instanceof Errors.NotFoundError && folder == null) { + return callback(new Error('folder_not_found')) + } return callback(error) } if (folder == null) { diff --git a/services/web/app/src/Features/Uploads/ProjectUploadController.js b/services/web/app/src/Features/Uploads/ProjectUploadController.js index f61563c4ff..0038a92cf0 100644 --- a/services/web/app/src/Features/Uploads/ProjectUploadController.js +++ b/services/web/app/src/Features/Uploads/ProjectUploadController.js @@ -120,6 +120,11 @@ module.exports = ProjectUploadController = { success: false, error: 'project_has_too_many_files', }) + } else if (error.message === 'folder_not_found') { + return res.status(422).json({ + success: false, + error: 'folder_not_found', + }) } else { return res.status(422).json({ success: false }) } diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 6d8731dddb..2e17865776 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -1270,6 +1270,7 @@ "thanks_for_subscribing_you_help_sl": "", "thanks_settings_updated": "", "the_following_files_already_exist_in_this_project": "", + "the_target_folder_could_not_be_found": "", "the_width_you_choose_here_is_based_on_the_width_of_the_text_in_your_document": "", "their_projects_will_be_transferred_to_another_user": "", "then_x_price_per_month": "", diff --git a/services/web/frontend/js/features/file-tree/components/file-tree-create/error-message.jsx b/services/web/frontend/js/features/file-tree/components/file-tree-create/error-message.jsx index ef0c54429c..ea618d48a1 100644 --- a/services/web/frontend/js/features/file-tree/components/file-tree-create/error-message.jsx +++ b/services/web/frontend/js/features/file-tree/components/file-tree-create/error-message.jsx @@ -26,6 +26,13 @@ export default function ErrorMessage({ error }) { case 'remote-service-error': return {t('remote_service_error')} + case 'folder_not_found': + return ( + + {t('the_target_folder_could_not_be_found')} + + ) + case 'invalid_filename': return ( diff --git a/services/web/locales/en.json b/services/web/locales/en.json index d77183a9b5..5d1aecc415 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -1873,6 +1873,7 @@ "the_required_parameters_were_not_supplied": "The link to open this content on Overleaf was missing some required parameters. If this keeps happening for links on a particular site, please report this to them.", "the_supplied_parameters_were_invalid": "The link to open this content on Overleaf included some invalid parameters. If this keeps happening for links on a particular site, please report this to them.", "the_supplied_uri_is_invalid": "The link to open this content on Overleaf included an invalid URI. If this keeps happening for links on a particular site, please report this to them.", + "the_target_folder_could_not_be_found": "The target folder could not be found.", "the_width_you_choose_here_is_based_on_the_width_of_the_text_in_your_document": "The width you choose here is based on the width of the text in your document. Alternatively, you can customize the image size directly in the LaTeX code.", "their_projects_will_be_transferred_to_another_user": "Their projects will all be transferred to another user of your choice", "theme": "Theme",