🐛 修复 BUG

This commit is contained in:
Wisp X 2022-03-06 21:32:41 +08:00
parent 4ea2f28fd4
commit cebf64a4bb
2 changed files with 16 additions and 1 deletions

View File

@ -66,7 +66,7 @@ class Strategy extends Model
$symlink = self::getRootPath($strategy->configs['url']); $symlink = self::getRootPath($strategy->configs['url']);
$target = $strategy->configs['root'] ?: config('filesystems.disks.uploads.root'); $target = $strategy->configs['root'] ?: config('filesystems.disks.uploads.root');
if (! is_dir(public_path($symlink))) { if (! is_dir(public_path($symlink))) {
@(new Filesystem())->link($target, $symlink); (new Filesystem())->link($target, $symlink);
} }
// 是否需要移除旧的符号链接 // 是否需要移除旧的符号链接
$url = $strategy->getOriginal('configs')['url'] ?? ''; $url = $strategy->getOriginal('configs')['url'] ?? '';

View File

@ -9,10 +9,25 @@ abstract class TestCase extends BaseTestCase
{ {
use CreatesApplication; use CreatesApplication;
protected array $links = [];
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->links = \config('filesystems.links');
$this->seed(InstallSeeder::class); $this->seed(InstallSeeder::class);
} }
protected function tearDown(): void
{
parent::tearDown();
foreach (array_flip($this->links) as $link) {
@unlink($link);
// 因 phpunit 运行时根目录和 env 同级,所以创建的符号链接被放到了根目录
// 清理根目录生成的符号链接
@unlink(str_replace('/public', '', $link));
}
}
} }