Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(suite-desktop-core): use checkFileExits form node-utils #13662

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions packages/suite-desktop-core/src/modules/udev-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,14 @@ 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';

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 = () => {
Expand All @@ -35,15 +24,15 @@ 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.
// TODO: should override anyway?
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/...)
Expand Down
Loading