File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
src/Illuminate/Foundation/Console Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ class StorageLinkCommand extends Command
11
11
*
12
12
* @var string
13
13
*/
14
- protected $ signature = 'storage:link {--relative : Create the symbolic link using relative paths} ' ;
14
+ protected $ signature = 'storage:link
15
+ {--relative : Create the symbolic link using relative paths}
16
+ {--force : Recreate existing symbolic links} ' ;
15
17
16
18
/**
17
19
* The console command description.
@@ -30,7 +32,7 @@ public function handle()
30
32
$ relative = $ this ->option ('relative ' );
31
33
32
34
foreach ($ this ->links () as $ link => $ target ) {
33
- if (file_exists ($ link )) {
35
+ if (file_exists ($ link ) && ! $ this -> removableSymlink ( $ link , $ this -> option ( ' force ' )) ) {
34
36
$ this ->error ("The [ $ link] link already exists. " );
35
37
continue ;
36
38
}
@@ -61,4 +63,16 @@ protected function links()
61
63
return $ this ->laravel ['config ' ]['filesystems.links ' ] ??
62
64
[public_path ('storage ' ) => storage_path ('app/public ' )];
63
65
}
66
+
67
+ /**
68
+ * Determine if the provided path is a symlink that can be removed.
69
+ *
70
+ * @param string $link
71
+ * @param bool $force
72
+ * @return bool
73
+ */
74
+ protected function removableSymlink (string $ link , bool $ force ): bool
75
+ {
76
+ return is_link ($ link ) && $ force ;
77
+ }
64
78
}
You can’t perform that action at this time.
0 commit comments