Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c07e916

Browse files
committed
merged branch SamsonIT/remove_symlink_on_windows (PR #4565)
Commits ------- fc3ebb8 [FileSystem] added if-windows check 0b58828 [FileSystem] remove symlinks under windows Discussion ---------- [FileSystem] remove symlinks under windows Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes When installing assets on Windows with symlink, the following error occurs when symlink-folders already exist. This PR makes sure symlink-folders are removed under Windows. ``` $ app/console assets:install web --symlink Installing assets using the symlink option Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework [ErrorException] Warning: symlink(): Cannot create symlink, error code(1314) in C:\workspace\erik\roompot\vendor\symfony\symfony\src\Symfony\Component\Filesystem\Filesystem.php line 167 assets:install [--symlink] [--relative] target ``` --------------------------------------------------------------------------- by travisbot at 2012-06-13T09:00:42Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1608541) (merged 0b58828 into 37550d2). --------------------------------------------------------------------------- by travisbot at 2012-06-13T14:39:32Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1611288) (merged fc3ebb8 into 0f67ca8).
2 parents 0f67ca8 + fc3ebb8 commit c07e916

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ public function remove($files)
9797

9898
rmdir($file);
9999
} else {
100-
unlink($file);
100+
// https://bugs.php.net/bug.php?id=52176
101+
if (defined('PHP_WINDOWS_VERSION_MAJOR') && is_dir($file)) {
102+
rmdir($file);
103+
} else {
104+
unlink($file);
105+
}
101106
}
102107
}
103108
}

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,20 @@ public function testSymlink()
421421
$this->assertTrue(is_link($link));
422422
$this->assertEquals($file, readlink($link));
423423
}
424+
425+
/**
426+
* @depends testSymlink
427+
*/
428+
public function testRemoveSymlink()
429+
{
430+
$this->markAsSkippedIfSymlinkIsMissing();
431+
432+
$link = $this->workspace.DIRECTORY_SEPARATOR.'link';
433+
434+
$this->filesystem->remove($link);
435+
436+
$this->assertTrue(!is_link($link));
437+
}
424438

425439
public function testSymlinkIsOverwrittenIfPointsToDifferentTarget()
426440
{

0 commit comments

Comments
 (0)