From db3bbc0aea56958241398a88c973558a64c23798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Fri, 8 Dec 2023 12:15:46 +0100 Subject: [PATCH] [PM-5144] Use sync fs in desktop i18n loading (#7114) --- apps/desktop/src/platform/services/i18n.main.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src/platform/services/i18n.main.service.ts b/apps/desktop/src/platform/services/i18n.main.service.ts index 60f641cd59..0170c934fd 100644 --- a/apps/desktop/src/platform/services/i18n.main.service.ts +++ b/apps/desktop/src/platform/services/i18n.main.service.ts @@ -1,4 +1,4 @@ -import { promises as fs } from "fs"; +import * as fs from "fs"; import * as path from "path"; import { ipcMain } from "electron"; @@ -76,14 +76,14 @@ export class I18nMainService extends BaseI18nService { ]; } - private async readLanguageFile(formattedLocale: string): Promise { + private readLanguageFile(formattedLocale: string): Promise { // Check that the provided locale only contains letters and dashes and underscores to avoid possible path traversal if (!/^[a-zA-Z_-]+$/.test(formattedLocale)) { return Promise.resolve({}); } const filePath = path.join(__dirname, this.localesDirectory, formattedLocale, "messages.json"); - const localesJson = await fs.readFile(filePath, "utf8"); + const localesJson = fs.readFileSync(filePath, "utf8"); const locales = JSON.parse(localesJson.replace(/^\uFEFF/, "")); // strip the BOM return Promise.resolve(locales); }