[Paths] Move setting globals and cleanOldVersions into paths itself
This commit is contained in:
parent
99d1aff934
commit
cd2136a94e
2 changed files with 6 additions and 11 deletions
8
src/bootstrap.js
vendored
8
src/bootstrap.js
vendored
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 });
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue