forked from laysense/laysite
Address LaySite 1.4.0 review findings
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Content;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
final class UpdateCheckInProgress extends RuntimeException
|
||||
{
|
||||
}
|
||||
@@ -33,9 +33,12 @@ final class Updates
|
||||
throw new RuntimeException('无法打开版本检查缓存。');
|
||||
}
|
||||
try {
|
||||
if (!flock($lock, LOCK_EX | LOCK_NB)) {
|
||||
if (!flock($lock, LOCK_EX | LOCK_NB, $wouldBlock)) {
|
||||
if (!$wouldBlock) {
|
||||
throw new RuntimeException('无法锁定版本检查缓存。');
|
||||
}
|
||||
if (!array_key_exists('latest', $record)) {
|
||||
throw new RuntimeException('版本检查正在进行,请稍后重试。');
|
||||
throw new UpdateCheckInProgress('版本检查正在进行,请稍后重试。');
|
||||
}
|
||||
} else {
|
||||
$record = self::cached($path);
|
||||
|
||||
@@ -17,6 +17,7 @@ use App\Content\Passwords;
|
||||
use App\Content\Repository;
|
||||
use App\Content\SiteDesign;
|
||||
use App\Content\SystemInfo;
|
||||
use App\Content\UpdateCheckInProgress;
|
||||
use App\Content\Updates;
|
||||
use App\Content\View;
|
||||
use App\Http\Request;
|
||||
@@ -168,6 +169,8 @@ class AdminController
|
||||
}
|
||||
try {
|
||||
return $this->json(Updates::check());
|
||||
} catch (UpdateCheckInProgress $error) {
|
||||
return $this->json(['message' => $error->getMessage()], 409);
|
||||
} catch (RuntimeException $error) {
|
||||
return $this->json(['message' => $error->getMessage()], 502);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ $systemLabel = SystemPage::TYPES[$page['page_type']] ?? null;
|
||||
]) ?>
|
||||
</aside>
|
||||
<div class="studio-workspace">
|
||||
<section class="admin-panel studio-preview" data-preview-studio aria-labelledby="studio-preview-title">
|
||||
<section class="admin-panel studio-preview" data-preview-studio aria-labelledby="studio-preview-title" tabindex="-1">
|
||||
<div class="admin-heading compact">
|
||||
<h2 id="studio-preview-title">页面画布</h2>
|
||||
<div class="preview-selector" aria-label="预览尺寸">
|
||||
|
||||
Reference in New Issue
Block a user