-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Make assets:install smarter with symlinks #11312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8634199
Make assets:install auto
rvanginneken f03073e
assets:install:auto removed unnecessary function_exists calls: as of …
rvanginneken a7330c3
assets:install cleaned up code
rvanginneken 2ea12de
assets:install as mentioned; removed unused itterator from function
rvanginneken 25b456b
assets:install removed faulty false check
rvanginneken 421de05
assets:install --auto -> check if running on windows, if so, use nati…
rvanginneken ba950dc
assets:install --auto -> removed mklink functionality, kept onWindows…
rvanginneken 21c85f9
assets:install --auto -> removed --auto param and integrated function…
rvanginneken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,9 +268,10 @@ public function rename($origin, $target, $overwrite = false) | |
*/ | ||
public function symlink($originDir, $targetDir, $copyOnWindows = false) | ||
{ | ||
if (!function_exists('symlink') && $copyOnWindows) { | ||
$this->mirror($originDir, $targetDir); | ||
$onWindows = strtoupper(substr(php_uname('s'), 0, 3)) === 'WIN'; | ||
|
||
if ($onWindows && $copyOnWindows) { | ||
$this->mirror($originDir, $targetDir); | ||
return; | ||
} | ||
|
||
|
@@ -293,9 +294,12 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false) | |
throw new IOException('Unable to create symlink due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?'); | ||
} | ||
} | ||
|
||
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); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need someone on a VM that has a Windows host machine (and where the project files are shared with the host machine) to try this and see if this properly catches the failure: #11297 (comment) |
||
} | ||
} | ||
|
||
|
@@ -374,7 +378,7 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o | |
} | ||
|
||
$copyOnWindows = false; | ||
if (isset($options['copy_on_windows']) && !function_exists('symlink')) { | ||
if (isset($options['copy_on_windows'])) { | ||
$copyOnWindows = $options['copy_on_windows']; | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks perfect, but I don't think that it'll catch the case where you're on a VM with a Windows host machine, you're sharing the Symfony directory with the host machine, and you don't have proper permissions to actually create symlinks on the Windows machine (see: #11297 (comment)).
The reason I don't think that this will work for that one case is that I don't think these users are currently seeing an
IOException
- theassets:install
just thinks that symlinks work (I could be wrong here, but pretty sure I'm not).So, I think we need to actually check for the integrity of the symlink - e.g. can you look inside of its contents or not. This could actually go into the
Filesystem::symlink
method, if we could find a clean way, consistent way of doing this check.