Repository navigation
fix: a failed storage link says so and how to make it #45
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -795,7 +795,15 @@ protected function resolveModuleSelection(array $available): array | |
|
|
||
| protected function createStorageLink(): void | ||
| { | ||
| $this->task('Creating storage link', fn () => $this->runArtisan(['storage:link'])); | ||
| if (! $this->task('Creating storage link', fn () => $this->runArtisan(['storage:link']))) { | ||
| $this->warnNoStorageLink('php artisan storage:link'); | ||
| } | ||
| } | ||
|
|
||
| /** The app runs without the link, so the install goes on. */ | ||
| public function warnNoStorageLink(string $fix): void | ||
| { | ||
| $this->warn("No storage link: uploaded files will not show until you run `{$fix}`"); | ||
|
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. Include the target directory in the recovery command. If installation uses When the target differs from the current directory, prefix the command with
|
||
| } | ||
|
|
||
| protected function clearCaches(): void | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| <?php | ||
|
|
||
| namespace Saucebase\Installer\Tests\Feature; | ||
|
|
||
| use Illuminate\Support\Facades\Process; | ||
| use Saucebase\Installer\Tests\TestCase; | ||
|
|
||
| /** Every driver but Docker makes the link on this machine. */ | ||
| class NativeStorageLinkTest extends TestCase | ||
| { | ||
| public function test_a_failed_link_says_what_is_missing_and_how_to_make_it(): void | ||
| { | ||
| $this->assertSame([], $this->link(exitCode: 0)); | ||
| $this->assertSame( | ||
| ['No storage link: uploaded files will not show until you run `php artisan storage:link`'], | ||
| $this->link(exitCode: 1), | ||
| ); | ||
| } | ||
|
|
||
| /** @return string[] The warnings printed. */ | ||
| private function link(int $exitCode): array | ||
| { | ||
| Process::fake(['*' => Process::result(exitCode: $exitCode)]); | ||
|
|
||
| $command = new class extends TestableInstallCommand | ||
| { | ||
| /** @var string[] */ | ||
| public array $warned = []; | ||
|
|
||
| public function link(): void | ||
| { | ||
| $this->components = new class | ||
| { | ||
| public function task(string $label, callable $task): void | ||
| { | ||
| $task(); | ||
| } | ||
| }; | ||
|
|
||
| $this->createStorageLink(); | ||
| } | ||
|
|
||
| public function warn($string, $verbosity = null): void | ||
| { | ||
| $this->warned[] = $string; | ||
| } | ||
| }; | ||
| $command->fakeOptions = ['path' => sys_get_temp_dir()]; | ||
| $command->link(); | ||
|
|
||
| return $command->warned; | ||
| } | ||
| } |
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.
A real
public/storagedirectory produces no storage-link warning.If
public/storagealready exists as a real directory,storage:linkdoes not create the link. Laravel 13.x reports "already exists" and continues without a failure status. That path can exit 0. The installer then treats the step as successful and skips the warning. Uploaded files will not appear in the app, and the user gets no recovery command.Check the link state after the command runs, for example whether
public/storageis a symlink tostorage/app/public. Show the warning when the link is missing. Keep the installer nonfatal, as it is now.