fix mirroring directory into parent directory
This commit is contained in:
parent
a25c2af559
commit
b58a806340
@ -569,14 +569,15 @@ class Filesystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->mkdir($targetDir);
|
$this->mkdir($targetDir);
|
||||||
$targetDirInfo = new \SplFileInfo($targetDir);
|
$filesCreatedWhileMirroring = [];
|
||||||
|
|
||||||
foreach ($iterator as $file) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$target = $targetDir.substr($file->getPathname(), $originDirLen);
|
$target = $targetDir.substr($file->getPathname(), $originDirLen);
|
||||||
|
$filesCreatedWhileMirroring[$target] = true;
|
||||||
|
|
||||||
if (!$copyOnWindows && is_link($file)) {
|
if (!$copyOnWindows && is_link($file)) {
|
||||||
$this->symlink($file->getLinkTarget(), $target);
|
$this->symlink($file->getLinkTarget(), $target);
|
||||||
|
@ -1362,6 +1362,22 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
$this->assertFalse($this->filesystem->exists($targetPath.'target'));
|
$this->assertFalse($this->filesystem->exists($targetPath.'target'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMirrorFromSubdirectoryInToParentDirectory()
|
||||||
|
{
|
||||||
|
$targetPath = $this->workspace.\DIRECTORY_SEPARATOR.'foo'.\DIRECTORY_SEPARATOR;
|
||||||
|
$sourcePath = $targetPath.'bar'.\DIRECTORY_SEPARATOR;
|
||||||
|
$file1 = $sourcePath.'file1';
|
||||||
|
$file2 = $sourcePath.'file2';
|
||||||
|
|
||||||
|
$this->filesystem->mkdir($sourcePath);
|
||||||
|
file_put_contents($file1, 'FILE1');
|
||||||
|
file_put_contents($file2, 'FILE2');
|
||||||
|
|
||||||
|
$this->filesystem->mirror($sourcePath, $targetPath);
|
||||||
|
|
||||||
|
$this->assertFileEquals($file1, $targetPath.'file1');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providePathsForIsAbsolutePath
|
* @dataProvider providePathsForIsAbsolutePath
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user