Skip to content
Snippets Groups Projects

Issue #3463205: Catch FileNotExistsException and allow processing to continue

Open Issue #3463205: Catch FileNotExistsException and allow processing to continue
1 unresolved thread
1 unresolved thread

Closes #3463205

Merge request reports

Members who can merge are allowed to add commits.
Approval is optional
Ready to merge by members who can write to the target branch.
  • The source branch is 1 commit behind the target branch.
  • 1 commit will be added to 8.x-1.x.
  • Source branch will not be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
59 60 $targetDirectory = dirname($fileTargetUri);
60 61 $fileSystemService->prepareDirectory($targetDirectory, FileSystemInterface::CREATE_DIRECTORY);
61 62 // This will notify modules, e.f. for image derivations.
62 $movedFile = \Drupal::service('file.repository')->move($file, $fileTargetUri, FileSystemInterface::EXISTS_RENAME);
63 try {
64 $movedFile = \Drupal::service('file.repository')->move($file, $fileTargetUri, FileSystemInterface::EXISTS_RENAME);
65 }
66 catch (FileNotExistsException $e) {
67 \Drupal::logger('file_access_fix')->error('Exception thrown while moving file at @uri. @message', [
68 '@uri' => $file->getFileUri(),
69 '@message' => $e->getMessage(),
70 ]);
71 continue;
72 }
63 73 if (!$movedFile) {
  • I think catching the exception and logging it makes sense - I'm curious if that was always the intent of this code here - it looks like FileRepository::move either returns the file entity or throws an exception - I'm not sure if it ever evaluates to false for this logging code below to execute?

    Edited by Eric Smith
  • Please register or sign in to reply
Please register or sign in to reply
Loading