Skip to content

Commit e4b509e

Browse files
committed
Extract removable symlink check to method
1 parent 968a364 commit e4b509e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Illuminate/Foundation/Console/StorageLinkCommand.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function handle()
3333
$force = $this->option('force');
3434

3535
foreach ($this->links() as $link => $target) {
36-
if (file_exists($link) && ! (is_link($link) && $force)) {
36+
if (file_exists($link) && ! $this->removableSymlink($link, $force)) {
3737
$this->error("The [$link] link already exists.");
3838
continue;
3939
}
@@ -64,4 +64,16 @@ protected function links()
6464
return $this->laravel['config']['filesystems.links'] ??
6565
[public_path('storage') => storage_path('app/public')];
6666
}
67+
68+
/**
69+
* Checks that the provided path is a symlink and force option is turned on.
70+
*
71+
* @param string $link
72+
* @param bool $force
73+
* @return bool
74+
*/
75+
protected function removableSymlink(string $link, bool $force): bool
76+
{
77+
return is_link($link) && $force;
78+
}
6779
}

0 commit comments

Comments
 (0)