From 2b64e7ade97f3f99dcf3de0e0de91a16c8e4a625 Mon Sep 17 00:00:00 2001 From: Alexander Rodionov Date: Thu, 5 Oct 2023 16:25:06 +0400 Subject: [PATCH] refactor: remove config file existing checks --- src/Config/SystemConfigReader.ts | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/Config/SystemConfigReader.ts b/src/Config/SystemConfigReader.ts index c932618c..9e5b49a8 100644 --- a/src/Config/SystemConfigReader.ts +++ b/src/Config/SystemConfigReader.ts @@ -1,11 +1,10 @@ import { logger } from '../Utils'; import request, { RequestPromiseAPI } from 'request-promise'; -import { promises, constants } from 'fs'; +import { promises } from 'fs'; import { join } from 'path'; import { homedir } from 'os'; -const { readFile, writeFile, access } = promises; -const { F_OK } = constants; +const { readFile, writeFile } = promises; export interface SystemConfig { sentryDsn?: string; @@ -98,16 +97,6 @@ export class SystemConfigReader { try { logger.debug('Loading system config file'); - const configFileExists = await this.configFileExists(); - - if (!configFileExists) { - logger.debug( - "System config file doesn't exist. Creating a new one with default values" - ); - - await this.updateConfigFile(defaultConfigFile); - } - const file = await readFile(this.path); const fileConfig = JSON.parse(file.toString()) as SystemConfigFile; @@ -133,16 +122,6 @@ export class SystemConfigReader { } } - private async configFileExists(): Promise { - try { - await access(this.path, F_OK); - - return true; - } catch (e) { - return false; - } - } - private async fetchNewConfig(): Promise { logger.debug('Fetching new system config');