Skip to content

Commit

Permalink
merged branch SamsonIT/remove_symlink_on_windows (PR symfony#4565)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
fabpot committed Jun 13, 2012
2 parents 0f67ca8 + fc3ebb8 commit c07e916
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Symfony/Component/Filesystem/Filesystem.php
Expand Up @@ -97,7 +97,12 @@ public function remove($files)

rmdir($file);
} else {
unlink($file);
// https://bugs.php.net/bug.php?id=52176
if (defined('PHP_WINDOWS_VERSION_MAJOR') && is_dir($file)) {
rmdir($file);
} else {
unlink($file);
}
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
Expand Up @@ -421,6 +421,20 @@ public function testSymlink()
$this->assertTrue(is_link($link));
$this->assertEquals($file, readlink($link));
}

/**
* @depends testSymlink
*/
public function testRemoveSymlink()
{
$this->markAsSkippedIfSymlinkIsMissing();

$link = $this->workspace.DIRECTORY_SEPARATOR.'link';

$this->filesystem->remove($link);

$this->assertTrue(!is_link($link));
}

public function testSymlinkIsOverwrittenIfPointsToDifferentTarget()
{
Expand Down

0 comments on commit c07e916

Please sign in to comment.