From 5e783fa5cd9e4296bf5f3069dc26c76fc02badc3 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Ortiz karliatto Date: Tue, 6 Aug 2024 10:16:02 +0200 Subject: [PATCH] fix(suite-desktop-core): use checkFileExits form node-utils --- .../src/modules/udev-install.ts | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/packages/suite-desktop-core/src/modules/udev-install.ts b/packages/suite-desktop-core/src/modules/udev-install.ts index 8ca97cc3768..de0e1aef7c4 100644 --- a/packages/suite-desktop-core/src/modules/udev-install.ts +++ b/packages/suite-desktop-core/src/modules/udev-install.ts @@ -3,6 +3,7 @@ import path from 'path'; import { spawn } from 'child_process'; import { validateIpcMessage } from '@trezor/ipc-proxy'; +import { checkFileExists } from '@trezor/node-utils'; import { app, ipcMain } from '../typed-electron'; @@ -10,18 +11,6 @@ import type { Module } from './index'; const FILE_NAME = '51-trezor.rules'; -const fileExists = async (filePath: string) => { - try { - await fs.promises.stat(filePath); - - return true; - } catch (error) { - // file is not present - } - - return false; -}; - export const SERVICE_NAME = 'udev'; export const init: Module = () => { @@ -35,7 +24,7 @@ export const init: Module = () => { logger.info(SERVICE_NAME, `Installing ${resourceRules} > ${userRules} > ${distRules}`); - if (await fileExists(distRules)) { + if (await checkFileExists(distRules)) { logger.error(SERVICE_NAME, `/etc/udev rules already installed: ${distRules}`); // /etc/udev already exists, break here. @@ -43,7 +32,7 @@ export const init: Module = () => { return { success: false, error: `File ${distRules} already exists` }; } - if (!(await fileExists(userRules))) { + if (!(await checkFileExists(userRules))) { try { logger.info(SERVICE_NAME, `Create user data rules: ${userRules}`); // copy rules from app resources (/tmp/...) to user data files (~/.cache/...)