Skip to content

Commit

Permalink
bug #32138 [Filesystem] fix mirroring directory into parent directory…
Browse files Browse the repository at this point in the history
… (xabbuh)

This PR was merged into the 4.3 branch.

Discussion
----------

[Filesystem] fix mirroring directory into parent directory

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #32089
| License       | MIT
| Doc PR        |

Commits
-------

b58a806 fix mirroring directory into parent directory
  • Loading branch information
fabpot committed Jun 26, 2019
2 parents a590829 + b58a806 commit c245f7c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Symfony/Component/Filesystem/Filesystem.php
Expand Up @@ -569,14 +569,15 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
}

$this->mkdir($targetDir);
$targetDirInfo = new \SplFileInfo($targetDir);
$filesCreatedWhileMirroring = [];

foreach ($iterator as $file) {
if ($file->getPathname() === $targetDir || $file->getRealPath() === $targetDir || 0 === strpos($file->getRealPath(), $targetDirInfo->getRealPath())) {
if ($file->getPathname() === $targetDir || $file->getRealPath() === $targetDir || isset($filesCreatedWhileMirroring[$file->getRealPath()])) {
continue;
}

$target = $targetDir.substr($file->getPathname(), $originDirLen);
$filesCreatedWhileMirroring[$target] = true;

if (!$copyOnWindows && is_link($file)) {
$this->symlink($file->getLinkTarget(), $target);
Expand Down

0 comments on commit c245f7c

Please sign in to comment.