From b4a619993696dede882209a5b5d0bcb855082c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Dalfors?= Date: Wed, 29 May 2024 10:02:00 +0200 Subject: [PATCH] Move file operation to backend --- app/src/actions/ConnectionManager.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/actions/ConnectionManager.ts b/app/src/actions/ConnectionManager.ts index fce8cbe..f9924b3 100644 --- a/app/src/actions/ConnectionManager.ts +++ b/app/src/actions/ConnectionManager.ts @@ -9,12 +9,11 @@ import { import { default as persistentStorage, StorageIdentifier } from '../utils/PersistentStorage' import { Dispatch } from 'redux' import { showError } from './Global' -import { promises as fsPromise } from 'fs' import * as path from 'path' import { ActionTypes, Action } from '../reducers/ConnectionManager' import { Subscription } from '../../../backend/src/DataSource/MqttSource' import { connectionsMigrator } from './migrations/Connection' -import { rendererRpc } from '../../../events' +import { rendererRpc, readFromFile } from '../../../events' import { makeOpenDialogRpc } from '../../../events/OpenDialogRequest' export interface ConnectionDictionary { @@ -81,7 +80,7 @@ async function openCertificate(): Promise { throw rejectReasons.noCertificateSelected } - const data = await fsPromise.readFile(selectedFile) + const data = await rendererRpc.call(readFromFile, { filePath: selectedFile }) if (data.length > 16_384 || data.length < 64) { throw rejectReasons.certificateSizeDoesNotMatch }