Bläddra i källkod

Improve handling of upload to deleted folder (#16738)

GitOrigin-RevId: 2ad2890f8fe51f3c7c7a8ac0834059ea9cb0557b
Alf Eaton 2 år sedan
förälder
incheckning
fefec2c1bf

+ 6 - 0
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) {

+ 5 - 0
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 })
           }

+ 1 - 0
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": "",

+ 7 - 0
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 <DangerMessage>{t('remote_service_error')}</DangerMessage>
 
+      case 'folder_not_found':
+        return (
+          <DangerMessage>
+            {t('the_target_folder_could_not_be_found')}
+          </DangerMessage>
+        )
+
       case 'invalid_filename':
         return (
           <DangerMessage>

+ 1 - 0
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",