Added option to change data folder location. (#17)

Removed commonDirectory.
Removed instanceDirectory.
Added dataDirectory. The common and instance directories are now resolved from this.
The config.json and distribution.json are now stored in Electron's data folder (app.getPath('userData')).
Users can edit the dataDirectory under launcher settings.
This commit is contained in:
Daniel Scalzi
2019-01-04 14:25:27 -05:00
parent e12197526d
commit de15440e6d
7 changed files with 223 additions and 143 deletions

View File

@@ -275,11 +275,15 @@ function asyncSystemScan(mcVersion, launchAfter = true){
const loggerSysAEx = LoggerUtil('%c[SysAEx]', 'color: #353232; font-weight: bold')
const forkEnv = JSON.parse(JSON.stringify(process.env))
forkEnv.CONFIG_DIRECT_PATH = ConfigManager.getLauncherDirectory()
// Fork a process to run validations.
sysAEx = cp.fork(path.join(__dirname, 'assets', 'js', 'assetexec.js'), [
ConfigManager.getCommonDirectory(),
ConfigManager.getJavaExecutable()
], {
env: forkEnv,
stdio: 'pipe'
})
// Stdout
@@ -307,7 +311,7 @@ function asyncSystemScan(mcVersion, launchAfter = true){
)
setOverlayHandler(() => {
setLaunchDetails('Preparing Java Download..')
sysAEx.send({task: 'execute', function: '_enqueueOracleJRE', argsArr: [ConfigManager.getLauncherDirectory()]})
sysAEx.send({task: 'execute', function: '_enqueueOracleJRE', argsArr: [ConfigManager.getDataDirectory()]})
toggleOverlay(false)
})
setDismissHandler(() => {
@@ -431,7 +435,7 @@ function asyncSystemScan(mcVersion, launchAfter = true){
// Begin system Java scan.
setLaunchDetails('Checking system info..')
sysAEx.send({task: 'execute', function: 'validateJava', argsArr: [ConfigManager.getLauncherDirectory(), mcVersion]})
sysAEx.send({task: 'execute', function: 'validateJava', argsArr: [ConfigManager.getDataDirectory(), mcVersion]})
}
@@ -470,11 +474,15 @@ function dlAsync(login = true){
const loggerAEx = LoggerUtil('%c[AEx]', 'color: #353232; font-weight: bold')
const loggerLaunchSuite = LoggerUtil('%c[LaunchSuite]', 'color: #000668; font-weight: bold')
const forkEnv = JSON.parse(JSON.stringify(process.env))
forkEnv.CONFIG_DIRECT_PATH = ConfigManager.getLauncherDirectory()
// Start AssetExec to run validations and downloads in a forked process.
aEx = cp.fork(path.join(__dirname, 'assets', 'js', 'assetexec.js'), [
ConfigManager.getCommonDirectory(),
ConfigManager.getJavaExecutable()
], {
env: forkEnv,
stdio: 'pipe'
})
// Stdout

View File

@@ -41,6 +41,24 @@ document.addEventListener('click', closeSettingsSelect)
bindSettingsSelect()
function bindFileSelectors(){
for(let ele of document.getElementsByClassName('settingsFileSelSel')){
if(ele.id === 'settingsJavaExecSel'){
ele.onchange = (e) => {
ele.previousElementSibling.value = ele.files[0].path
populateJavaExecDetails(ele.previousElementSibling.value)
}
} else {
ele.onchange = (e) => {
ele.previousElementSibling.value = ele.files[0].path
}
}
}
}
bindFileSelectors()
/**
* General Settings Functions
*/
@@ -97,6 +115,8 @@ function initSettingsValues(){
if(cVal === 'JavaExecutable'){
populateJavaExecDetails(v.value)
v.value = gFn()
} else if (cVal === 'DataDirectory'){
v.value = gFn()
} else if(cVal === 'JVMOptions'){
v.value = gFn().join(' ')
} else {
@@ -905,8 +925,6 @@ const settingsMinRAMLabel = document.getElementById('settingsMinRAMLabel')
const settingsMemoryTotal = document.getElementById('settingsMemoryTotal')
const settingsMemoryAvail = document.getElementById('settingsMemoryAvail')
const settingsJavaExecDetails = document.getElementById('settingsJavaExecDetails')
const settingsJavaExecVal = document.getElementById('settingsJavaExecVal')
const settingsJavaExecSel = document.getElementById('settingsJavaExecSel')
// Store maximum memory values.
const SETTINGS_MAX_MEMORY = ConfigManager.getAbsoluteMaxRAM()
@@ -1092,12 +1110,6 @@ function populateMemoryStatus(){
settingsMemoryAvail.innerHTML = Number(os.freemem()/1000000000).toFixed(1) + 'G'
}
// Bind the executable file input to the display text input.
settingsJavaExecSel.onchange = (e) => {
settingsJavaExecVal.value = settingsJavaExecSel.files[0].path
populateJavaExecDetails(settingsJavaExecVal.value)
}
/**
* Validate the provided executable path and display the data on
* the UI.