mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-01-09 04:27:47 +08:00
Tweak path of options cache file
This commit is contained in:
parent
da422ab1e8
commit
0195b0fbd0
1
.gitignore
vendored
1
.gitignore
vendored
@ -22,6 +22,7 @@ storage/*.sqlite
|
||||
storage/oauth-public.key
|
||||
storage/oauth-private.key
|
||||
storage/install.lock
|
||||
storage/options.php
|
||||
.phpunit.result.cache
|
||||
.php_cs.cache
|
||||
resources/views/overrides
|
||||
|
@ -15,12 +15,13 @@ class OptionsCacheCommand extends Command
|
||||
|
||||
public function handle(Filesystem $filesystem, Application $app)
|
||||
{
|
||||
$path = storage_path('options/cache.php');
|
||||
$path = storage_path('options.php');
|
||||
$filesystem->delete($path);
|
||||
$app->forgetInstance(Option::class);
|
||||
|
||||
$content = var_export(resolve(Option::class)->all(), true);
|
||||
$content = '<?php'.PHP_EOL.'return '.$content.';';
|
||||
$notice = '// This is auto-generated. DO NOT edit manually.'.PHP_EOL;
|
||||
$content = '<?php'.PHP_EOL.$notice.'return '.$content.';';
|
||||
$filesystem->put($path, $content);
|
||||
$this->info('Options cached successfully.');
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class UpdateController extends Controller
|
||||
$package->download($this->info['url'], $path)->extract(base_path());
|
||||
|
||||
// Delete options cache. This allows us to update the version info which is recorded as an option.
|
||||
$filesystem->delete(storage_path('options/cache.php'));
|
||||
$filesystem->delete(storage_path('options.php'));
|
||||
|
||||
return json(trans('admin.update.complete'), 0);
|
||||
} catch (Exception $e) {
|
||||
|
@ -13,7 +13,7 @@ class Option
|
||||
|
||||
public function __construct(Filesystem $filesystem)
|
||||
{
|
||||
$cachePath = storage_path('options/cache.php');
|
||||
$cachePath = storage_path('options.php');
|
||||
if ($filesystem->exists($cachePath)) {
|
||||
$this->items = collect($filesystem->getRequire($cachePath));
|
||||
|
||||
|
2
storage/options/.gitignore
vendored
2
storage/options/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
*
|
||||
!.gitignore
|
@ -11,11 +11,11 @@ class OptionsCacheCommandTest extends TestCase
|
||||
{
|
||||
$this->mock(Filesystem::class, function ($mock) {
|
||||
$mock->shouldReceive('exists')->andReturn(false);
|
||||
$mock->shouldReceive('delete')->with(storage_path('options/cache.php'))->once();
|
||||
$mock->shouldReceive('delete')->with(storage_path('options.php'))->once();
|
||||
$mock->shouldReceive('put')
|
||||
->withArgs(function ($path, $content) {
|
||||
$this->assertEquals(storage_path('options/cache.php'), $path);
|
||||
$this->assertTrue(Str::startsWith($content, '<?php'.PHP_EOL.'return'));
|
||||
$this->assertEquals(storage_path('options.php'), $path);
|
||||
$this->assertTrue(Str::startsWith($content, '<?php'.PHP_EOL));
|
||||
$this->assertTrue(Str::endsWith($content, ';'));
|
||||
|
||||
return true;
|
||||
|
@ -93,7 +93,7 @@ class UpdateControllerTest extends TestCase
|
||||
$mock->shouldReceive('progress');
|
||||
});
|
||||
$this->mock(\Illuminate\Filesystem\Filesystem::class, function ($mock) {
|
||||
$mock->shouldReceive('delete')->with(storage_path('options/cache.php'))->once();
|
||||
$mock->shouldReceive('delete')->with(storage_path('options.php'))->once();
|
||||
$mock->shouldReceive('exists')->with(storage_path('install.lock'))->andReturn(true);
|
||||
});
|
||||
$this->getJson('/admin/update/download?action=download')
|
||||
|
@ -31,7 +31,7 @@ class OptionTest extends TestCase
|
||||
public function testReadFromCache()
|
||||
{
|
||||
$this->mock(\Illuminate\Filesystem\Filesystem::class, function ($mock) {
|
||||
$path = storage_path('options/cache.php');
|
||||
$path = storage_path('options.php');
|
||||
$mock->shouldReceive('exists')->with($path)->once()->andReturn(true);
|
||||
$mock->shouldReceive('getRequire')->with($path)->once()->andReturn(['k' => 'v']);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user