From ca030700e18e83fa5a4ddd9944247b19b79591bb Mon Sep 17 00:00:00 2001 From: Davide Ceschia Date: Thu, 2 May 2019 16:12:04 +0200 Subject: [PATCH] Added support for legacy config memory --- app/actions/instancesManager.js | 14 ++++++++++++++ app/actions/settings.js | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/actions/instancesManager.js b/app/actions/instancesManager.js index 7838fdb59..4da8f5ee3 100644 --- a/app/actions/instancesManager.js +++ b/app/actions/instancesManager.js @@ -3,9 +3,12 @@ import log from 'electron-log'; import { spawn } from 'child_process'; import path from 'path'; import { promisify } from 'util'; +import _ from 'lodash'; import fs from 'fs'; import launchCommand from '../utils/MCLaunchCommand'; import { PACKS_PATH } from '../constants'; +import { readConfig, updateConfig } from '../utils/instances'; +import { setJavaArgs } from './settings'; export const SELECT_INSTANCE = 'SELECT_INSTANCE'; export const START_INSTANCE = 'START_INSTANCE'; @@ -41,6 +44,17 @@ export function startInstance(instanceName) { return async (dispatch, getState) => { const { auth, settings } = getState(); + // Checks for legacy java memory + const legacyString = [' -Xmx{_RAM_}m', '-Xmx{_RAM_}m']; + const config = await readConfig(instanceName); + if (_.has(config, 'overrideArgs') && config.overrideArgs.includes(legacyString[0]) || config.overrideArgs.includes(legacyString[1])) { + await updateConfig(instanceName, { + overrideArgs: config.overrideArgs.replace(legacyString, '') + }); + } + if (settings.java.javaArgs.includes(legacyString[0]) || settings.java.javaArgs.includes(legacyString[1])) + dispatch(setJavaArgs(settings.java.javaArgs.replace(legacyString, ''))); + const command = await launchCommand( instanceName, auth, diff --git a/app/actions/settings.js b/app/actions/settings.js index 962b6e0c5..486fc6308 100644 --- a/app/actions/settings.js +++ b/app/actions/settings.js @@ -160,4 +160,3 @@ export function setJavaArgs(args) { dispatch(saveSettings()); }; } -