From cd2136a94e50f58fb072160a04ceae9feaea6d3e Mon Sep 17 00:00:00 2001 From: Oj Date: Tue, 29 Mar 2022 18:14:18 +0100 Subject: [PATCH] [Paths] Move setting globals and cleanOldVersions into paths itself --- src/bootstrap.js | 8 +------- src/paths.js | 9 +++++---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index 33a0b07..e6d97dd 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -8,10 +8,6 @@ process.env.PULSE_LATENCY_MSEC = process.env.PULSE_LATENCY_MSEC ?? 30; app.setAppUserModelId(Constants.APP_ID); app.name = 'discord'; // Force name as sometimes breaks -const paths = require('./paths'); -global.moduleDataPath = paths.getModuleDataPath(); // Global because discord -app.setPath('userData', paths.getUserData()); // Set userData properly because electron - const buildInfo = require('./utils/buildInfo'); app.setVersion(buildInfo.version); // More global because discord / electron global.releaseChannel = buildInfo.releaseChannel; @@ -37,13 +33,13 @@ const startCore = () => { log('Bootstrap', 'Required core'); desktopCore.startup({ - paths, splashScreen, moduleUpdater, buildInfo, appSettings, Constants, updater, + paths: require('./paths'), GPUSettings: require('./GPUSettings'), autoStart: require('./autoStart'), crashReporterSetup: require('./crashReporterSetup'), @@ -77,8 +73,6 @@ const startCore = () => { const startUpdate = async () => { const startMinimized = process.argv.includes('--start-minimized'); - paths.cleanOldVersions(); - appUpdater.update(startMinimized, () => { if (process.env.OPENASAR_NOSTART) return; diff --git a/src/paths.js b/src/paths.js index 1d250de..abc3c0b 100644 --- a/src/paths.js +++ b/src/paths.js @@ -26,12 +26,13 @@ exports.init = () => { moduleData = buildInfo.newUpdater ? join(userData, 'module_data') : join(userDataVersioned, 'modules'); resourcesPath = join(process.resourcesPath); -}; -exports.cleanOldVersions = () => { - if (!installPath) return; + global.moduleDataPath = moduleData; // Global because discord + app.setPath('userData', userData); // Set userData properly because electron - for (const x of fs.readdirSync(installPath)) { + + // cleanOldVersions + if (installPath) for (const x of fs.readdirSync(installPath)) { if (x.startsWith('app-') && !x.includes(buildInfo.version)) fs.rmSync(join(installPath, x), { recursive: true, force: true }); } }; \ No newline at end of file