Verified Commit cfcf382a authored by godotislate's avatar godotislate
Browse files

fix: #3615576 FileExistsException thrown in FileSystem::prepareDestination...

fix: #3615576 FileExistsException thrown in FileSystem::prepareDestination does not show destination path

By: shank115
By: kieran.cott
By: smustgrave
parent ac8820e1
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -459,9 +459,10 @@ protected function prepareDestination($source, &$destination, FileExists $fileEx
    }

    // Determine whether we can perform this operation based on overwrite rules.
    $original_destination = $destination;
    $destination = $this->getDestinationFilename($destination, $fileExists);
    if ($destination === FALSE) {
      throw new FileExistsException("File '$original_source' could not be copied because a file by that name already exists in the destination directory ('$destination').");
      throw new FileExistsException("File '$original_source' could not be copied because a file by that name already exists in the destination directory ('$original_destination').");
    }

    // Assert that the source and destination filenames are not the same.
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ public function testDestinationDirectoryFailureOnCopy(): void {
   */
  public function testCopyFailureIfFileAlreadyExists(): void {
    $this->expectException(FileExistsException::class);
    $this->expectExceptionMessageIs("File 'public://test.txt' could not be copied because a file by that name already exists in the destination directory ('').");
    $this->expectExceptionMessageIs("File 'public://test.txt' could not be copied because a file by that name already exists in the destination directory ('public://test.txt').");
    $uri = 'public://test.txt';
    touch($uri);
    $this->fileSystem->copy($uri, $uri, FileExists::Error);