This commit is contained in:
2026-07-07 17:00:05 +08:00
parent 48298ef1f7
commit aac6d5b80a
+13 -6
View File
@@ -239,8 +239,8 @@ class Router
); );
$scanner->setConfig($scanConfig); $scanner->setConfig($scanConfig);
$normalizedAppPath = str_replace('\\', '/', APP_PATH . 'app'); $normalizedAppPath = str_replace('\\', '/', realpath(APP_PATH . 'app') ?: APP_PATH . 'app');
$normalizedRoutePath = str_replace('\\', '/', APP_PATH . 'routes'); $normalizedRoutePath = str_replace('\\', '/', realpath(APP_PATH . 'routes') ?: APP_PATH . 'routes');
$routeChanged = false; $routeChanged = false;
$appChangedFiles = []; $appChangedFiles = [];
@@ -255,6 +255,10 @@ class Router
} }
} }
if (!empty($appChangedFiles)) {
$appChangedFiles = $scanner->expandDependentFiles($appChangedFiles, APP_PATH . 'app/');
}
$usedArtifact = false; $usedArtifact = false;
if (($scanConfig['cache_enabled'] ?? false) && !$routeChanged && $artifactState->has(static::$type)) { if (($scanConfig['cache_enabled'] ?? false) && !$routeChanged && $artifactState->has(static::$type)) {
$artifact = $artifactState->load(static::$type); $artifact = $artifactState->load(static::$type);
@@ -267,7 +271,7 @@ class Router
$this->read_dir_file(APP_PATH . 'routes'); $this->read_dir_file(APP_PATH . 'routes');
if (!$routeChanged && !empty($appChangedFiles) && ($scanConfig['cache_enabled'] ?? false)) { if (!$routeChanged && !empty($appChangedFiles) && ($scanConfig['cache_enabled'] ?? false)) {
$scanner->scanFiles($appChangedFiles, APP_PATH . 'app/', null, !$usedArtifact); $scanner->scanFiles($appChangedFiles, APP_PATH . 'app/', null, true);
} elseif (!$usedArtifact) { } elseif (!$usedArtifact) {
$scanner->scan(APP_PATH . 'app/'); $scanner->scan(APP_PATH . 'app/');
} else { } else {
@@ -462,8 +466,12 @@ class Router
private function resolve_file($files): void private function resolve_file($files): void
{ {
try { try {
static::$currentSourceFile = str_replace('\\', '/', realpath($files) ?: $files); $file = realpath($files) ?: $files;
include "$files"; static::$currentSourceFile = str_replace('\\\\', '/', $file);
if (function_exists('opcache_invalidate')) {
@opcache_invalidate($file, true);
}
include $file;
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
\Kiri::getLogger()->json_log($throwable); \Kiri::getLogger()->json_log($throwable);
} finally { } finally {
@@ -471,7 +479,6 @@ class Router
} }
} }
public static function getCurrentSourceFile(): ?string public static function getCurrentSourceFile(): ?string
{ {
return static::$currentSourceFile; return static::$currentSourceFile;