From f9eee54f2a601b8db7ebb7c11d149b39170e6d68 Mon Sep 17 00:00:00 2001 From: John Livingston <38844060+JohnXLivingston@users.noreply.github.com> Date: Wed, 10 May 2023 09:54:44 +0200 Subject: [PATCH] Fix #5744: Missing plugins-global.css + missing async (#5746) * Fix #5744: Missing plugins-global.css + missing async * Modifications required by Chocobozzz. * Styling --------- Co-authored-by: Chocobozzz --- server/lib/client-html.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index 8530cbcc2..058f29f03 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts @@ -1,5 +1,5 @@ import express from 'express' -import { readFile } from 'fs-extra' +import { pathExists, readFile } from 'fs-extra' import { join } from 'path' import validator from 'validator' import { isTestOrDevInstance } from '@server/helpers/core-utils' @@ -408,7 +408,20 @@ class ClientHtml { } private static async addAsyncPluginCSS (htmlStringPage: string) { - const globalCSSContent = await readFile(PLUGIN_GLOBAL_CSS_PATH) + if (!pathExists(PLUGIN_GLOBAL_CSS_PATH)) { + logger.info('Plugin Global CSS file is not available (generation may still be in progress), ignoring it.') + return htmlStringPage + } + + let globalCSSContent: Buffer + + try { + globalCSSContent = await readFile(PLUGIN_GLOBAL_CSS_PATH) + } catch (err) { + logger.error('Error retrieving the Plugin Global CSS file, ignoring it.', { err }) + return htmlStringPage + } + if (globalCSSContent.byteLength === 0) return htmlStringPage const fileHash = sha256(globalCSSContent)