From c4669e9cc32d34088ca6481accbcbdd0e9dd442d Mon Sep 17 00:00:00 2001 From: cubercsl <2014cais01@gmail.com> Date: Wed, 5 Nov 2025 19:24:38 +0800 Subject: [PATCH] Cache the results of getAssetFiles Fix the disk backlog during scoreboard pictures rendering. Signed-off-by: cubercsl <2014cais01@gmail.com> Co-authored-by: Soha Jin --- webapp/src/Service/DOMJudgeService.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/webapp/src/Service/DOMJudgeService.php b/webapp/src/Service/DOMJudgeService.php index cebc0fabe7..754c455149 100644 --- a/webapp/src/Service/DOMJudgeService.php +++ b/webapp/src/Service/DOMJudgeService.php @@ -1340,6 +1340,10 @@ public function apiRelativeUrl(string $route, array $params = []): string return substr($route, strlen($apiRootRoute) + $offset); } + + /** @var array */ + private static array $assetFiles = []; + /** * Get asset files in the given directory with the given extension * @@ -1347,9 +1351,13 @@ public function apiRelativeUrl(string $route, array $params = []): string */ public function getAssetFiles(string $path): array { + if (isset(self::$assetFiles[$path])) { + return self::$assetFiles[$path]; + } + $customDir = sprintf('%s/public/%s', $this->params->get('kernel.project_dir'), $path); if (!is_dir($customDir)) { - return []; + return self::$assetFiles[$path] = []; } $results = []; @@ -1361,7 +1369,7 @@ public function getAssetFiles(string $path): array } } - return $results; + return self::$assetFiles[$path] = $results; } /**