Compare commits
2
Commits
7bc8d04df3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf177c9158 | ||
|
|
23e9d79e27 |
+1
-21
@@ -91,27 +91,7 @@ class File
|
||||
*/
|
||||
private function exif_imageType(): ?int
|
||||
{
|
||||
return match (\exif_imagetype($this->tmp_name)) {
|
||||
IMAGETYPE_GIF => '.gif',
|
||||
IMAGETYPE_JPEG => '.jpg',
|
||||
IMAGETYPE_PNG => '.png',
|
||||
IMAGETYPE_SWF => '.swf',
|
||||
IMAGETYPE_PSD => '.psd',
|
||||
IMAGETYPE_BMP => '.bmp',
|
||||
IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM => '.tiff',
|
||||
IMAGETYPE_JPC => '.jpc',
|
||||
IMAGETYPE_JP2 => '.jp2',
|
||||
IMAGETYPE_JPX => '.jpx',
|
||||
IMAGETYPE_JB2 => '.jb2',
|
||||
IMAGETYPE_SWC => '.swc',
|
||||
IMAGETYPE_IFF => '.iff',
|
||||
IMAGETYPE_WBMP => '.wbmp',
|
||||
IMAGETYPE_XBM => '.xbm',
|
||||
IMAGETYPE_ICO => '.ico',
|
||||
IMAGETYPE_WEBP => '.webp',
|
||||
IMAGETYPE_AVIF => '.avif',
|
||||
default => throw new Exception('未知的图片类型'),
|
||||
};
|
||||
return exif_imagetype($this->tmp_name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+28
-6
@@ -216,16 +216,18 @@ class Router
|
||||
|
||||
$artifactState = $container->get(RouteArtifactState::class);
|
||||
if (getenv('KIRI_FILE_BUILD') !== '1' && !empty($changedFiles) && $artifactState->coversChangedFiles(static::$type, $changedFiles)) {
|
||||
$container->get(DataGrip::class)->reset(static::$type);
|
||||
$router = $container->get(DataGrip::class)->get(static::$type);
|
||||
if ($router->importArtifact($artifactState->load(static::$type))) {
|
||||
$this->read_dir_file(APP_PATH . 'routes');
|
||||
$this->reset($container);
|
||||
$coordinator->done();
|
||||
if ($this->importRouteArtifact($container, $artifactState, $coordinator)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getenv('KIRI_FILE_BUILD') !== '1' && empty($changedFiles) && (bool)config('servers.reload.hot', false) && $artifactState->has(static::$type)) {
|
||||
if ($this->importRouteArtifact($container, $artifactState, $coordinator)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Worker 首次启动(无变更文件 + Master 已完成扫描):
|
||||
// 重新 include 路由文件(Router::get/post 显式注册) + 基于 Master 扫描清单重建注解路由
|
||||
// 避免 opcache_compile_file,仅用 Reflection 重建路由,内存开销极小
|
||||
@@ -312,6 +314,26 @@ class Router
|
||||
}
|
||||
|
||||
|
||||
private function importRouteArtifact(ContainerInterface $container, RouteArtifactState $artifactState, Coordinator $coordinator): bool
|
||||
{
|
||||
$artifact = $artifactState->load(static::$type);
|
||||
$container->get(DataGrip::class)->reset(static::$type);
|
||||
$router = $container->get(DataGrip::class)->get(static::$type);
|
||||
if (!$router->importArtifact($artifact)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (($artifact['has_closure_routes'] ?? false) === true) {
|
||||
$this->read_dir_file(APP_PATH . 'routes');
|
||||
}
|
||||
|
||||
$this->reset($container);
|
||||
$coordinator->done();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 基于 Master 扫描清单重建注解路由(轻量级,无文件 I/O)
|
||||
* 遍历 Scanner manifest 中的所有类,用 Reflection 重新发现 #[Route]/#[Get] 等注解
|
||||
|
||||
Reference in New Issue
Block a user