Skip to content

Commit c245f7c

Browse files
committed
bug #32138 [Filesystem] fix mirroring directory into parent directory (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
2 parents a590829 + b58a806 commit c245f7c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,15 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
569569
}
570570

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

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

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

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

0 commit comments

Comments
 (0)