[Filesystem] restore ability to create broken symlinks
This commit is contained in:
parent
bad5169f0d
commit
3101202333
@ -106,6 +106,9 @@ EOT
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$filesystem->symlink($relativeOriginDir, $targetDir);
|
$filesystem->symlink($relativeOriginDir, $targetDir);
|
||||||
|
if (!file_exists($targetDir)) {
|
||||||
|
throw new IOException('Symbolic link is broken');
|
||||||
|
}
|
||||||
$output->writeln('The assets were installed using symbolic links.');
|
$output->writeln('The assets were installed using symbolic links.');
|
||||||
} catch (IOException $e) {
|
} catch (IOException $e) {
|
||||||
if (!$input->getOption('relative')) {
|
if (!$input->getOption('relative')) {
|
||||||
@ -116,6 +119,9 @@ EOT
|
|||||||
// try again without the relative option
|
// try again without the relative option
|
||||||
try {
|
try {
|
||||||
$filesystem->symlink($originDir, $targetDir);
|
$filesystem->symlink($originDir, $targetDir);
|
||||||
|
if (!file_exists($targetDir)) {
|
||||||
|
throw new IOException('Symbolic link is broken');
|
||||||
|
}
|
||||||
$output->writeln('It looks like your system doesn\'t support relative symbolic links, so the assets were installed by using absolute symbolic links.');
|
$output->writeln('It looks like your system doesn\'t support relative symbolic links, so the assets were installed by using absolute symbolic links.');
|
||||||
} catch (IOException $e) {
|
} catch (IOException $e) {
|
||||||
$this->hardCopy($originDir, $targetDir);
|
$this->hardCopy($originDir, $targetDir);
|
||||||
|
@ -286,9 +286,7 @@ class Filesystem
|
|||||||
*/
|
*/
|
||||||
public function symlink($originDir, $targetDir, $copyOnWindows = false)
|
public function symlink($originDir, $targetDir, $copyOnWindows = false)
|
||||||
{
|
{
|
||||||
$onWindows = strtoupper(substr(php_uname('s'), 0, 3)) === 'WIN';
|
if (defined('PHP_WINDOWS_VERSION_MAJOR') && $copyOnWindows) {
|
||||||
|
|
||||||
if ($onWindows && $copyOnWindows) {
|
|
||||||
$this->mirror($originDir, $targetDir);
|
$this->mirror($originDir, $targetDir);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -315,10 +313,6 @@ class Filesystem
|
|||||||
}
|
}
|
||||||
throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir);
|
throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($targetDir)) {
|
|
||||||
throw new IOException(sprintf('Symbolic link "%s" is created but appears to be broken.', $targetDir), 0, null, $targetDir);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,11 +686,14 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||||
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
|
||||||
|
|
||||||
touch($file);
|
// $file does not exists right now: creating "broken" links is a wanted feature
|
||||||
|
|
||||||
$this->filesystem->symlink($file, $link);
|
$this->filesystem->symlink($file, $link);
|
||||||
|
|
||||||
$this->assertTrue(is_link($link));
|
$this->assertTrue(is_link($link));
|
||||||
|
|
||||||
|
// Create the linked file AFTER creating the link
|
||||||
|
touch($file);
|
||||||
|
|
||||||
$this->assertEquals($file, readlink($link));
|
$this->assertEquals($file, readlink($link));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user