Skip to content

Commit 18daf46

Browse files
authored
Delete existing links that are broken (#36470)
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.
1 parent a817662 commit 18daf46

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Illuminate/Foundation/Console/StorageLinkCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public function handle()
3131
return $this->error('The "public/storage" directory already exists.');
3232
}
3333

34+
if (is_link(public_path('storage'))) {
35+
$this->laravel->make('files')->delete(public_path('storage'));
36+
}
37+
3438
$this->laravel->make('files')->link(
3539
storage_path('app/public'), public_path('storage')
3640
);

0 commit comments

Comments
 (0)