refactor: modify AppServiceProvider to silently handle symlink creation failures and improve user guidance for storage link management
This commit is contained in:
@@ -181,8 +181,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
@unlink($publicStoragePath);
|
||||
} elseif (is_dir($publicStoragePath)) {
|
||||
// If it's a directory, we can't safely remove it automatically
|
||||
// Log a warning instead
|
||||
\Log::warning('Storage symlink cannot be created: public/storage exists as a directory. Please remove it manually and run: php artisan storage:link');
|
||||
// Skip silently - the user is aware of this situation
|
||||
return;
|
||||
} else {
|
||||
@unlink($publicStoragePath);
|
||||
@@ -212,19 +211,16 @@ class AppServiceProvider extends ServiceProvider
|
||||
str_replace('/', '\\', $target)
|
||||
);
|
||||
@exec($command, $output, $return);
|
||||
if ($return !== 0) {
|
||||
\Log::warning('Storage symlink creation failed on Windows. Please run: php artisan storage:link');
|
||||
}
|
||||
} else {
|
||||
\Log::warning('Storage symlink cannot be created on Windows. Please run: php artisan storage:link');
|
||||
// Silently ignore if symlink creation fails on Windows
|
||||
}
|
||||
// Skip silently if exec is not available on Windows
|
||||
} else {
|
||||
// Unix/Linux - create symlink
|
||||
symlink($target, $link);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::warning('Storage symlink creation failed: ' . $e->getMessage() . '. Please run: php artisan storage:link');
|
||||
// Silently ignore symlink creation failures
|
||||
}
|
||||
} elseif (is_link($publicStoragePath)) {
|
||||
// Check if symlink is broken (points to non-existent target)
|
||||
|
||||
Reference in New Issue
Block a user