Skip to content

Conversation

@pgrenaud
Copy link
Contributor

@pgrenaud pgrenaud commented Mar 4, 2021

This PR attempt to fix an issue that occur when the storage link already exists but is somehow broken. By "broken", I mean link that point to a non-existing target.

When running the storage:link command, we get an error message and the link is not updated.

$ php artisan storage:link

In Filesystem.php line 263:
                                        
  symlink(): No such file or directory  
                                        

To fix this issue, we add an additional check to detect and delete broken links when running the storage:link command.

Implementation details

When a link exists but is broken, file_exists($link) return false. And when symlink($link, $target) is called on a broken link, a PHP Warning is returned and the link is not updated. To fix this, we add an additional check using is_link($link) (which return true, even if the link is broken) to detect and delete broken links.

When a link exists but is broken, `file_exists($link)` return false. And
when `symlink($link, $target)` is called on a broken link, a PHP Warning
is returned and the link is not updated. To fix this, we add an
additional check using `is_link($link)` (which return true, even if the
link is broken) to detect and delete broken links.
@GrahamCampbell GrahamCampbell changed the title Delete existing links that are broken [6.x] Delete existing links that are broken Mar 4, 2021
@taylorotwell taylorotwell merged commit 18daf46 into laravel:6.x Mar 5, 2021
This was referenced Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants