mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 03:37:17 +02:00
Add suppression of download if data exists
This commit is contained in:
parent
40a9efb248
commit
9ee65396b4
1 changed files with 28 additions and 19 deletions
|
@ -14,7 +14,6 @@ const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const Tail = require('always-tail');
|
const Tail = require('always-tail');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const path = require('path');
|
|
||||||
const unzip = require('unzip');
|
const unzip = require('unzip');
|
||||||
|
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
|
@ -29,14 +28,23 @@ const ProcessStates = hfprocess.ProcessStates;
|
||||||
const ProcessGroup = hfprocess.ProcessGroup;
|
const ProcessGroup = hfprocess.ProcessGroup;
|
||||||
const ProcessGroupStates = hfprocess.ProcessGroupStates;
|
const ProcessGroupStates = hfprocess.ProcessGroupStates;
|
||||||
|
|
||||||
|
const osType = os.type();
|
||||||
|
|
||||||
|
const APP_ICON = path.join(__dirname, '../resources/console.png');
|
||||||
|
|
||||||
function getRootHifiDataDirectory() {
|
function getRootHifiDataDirectory() {
|
||||||
var rootDirectory = app.getPath('appData');
|
if (osType == 'Windows_NT') {
|
||||||
return path.join(rootDirectory, '/High Fidelity');
|
var homePath = process.env.HOMEPATH;
|
||||||
|
return path.join(homePath, 'AppData/Roaming/High Fidelity');
|
||||||
|
} else if (osType == 'Darwin') {
|
||||||
|
return '~/Library/Application Support/High Fidelity';
|
||||||
|
} else {
|
||||||
|
return '/usr/local/share/High Fidelity';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStackManagerDataDirectory() {
|
function getStackManagerDataDirectory() {
|
||||||
return path.join(getRootHifiDataDirectory(), "../../Local/High Fidelity");
|
// return path.join(getRootHifiDataDirectory(), '../../Local/High Fidelity');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAssignmentClientResourcesDirectory() {
|
function getAssignmentClientResourcesDirectory() {
|
||||||
|
@ -47,12 +55,10 @@ function getApplicationDataDirectory() {
|
||||||
return path.join(getRootHifiDataDirectory(), '/Console');
|
return path.join(getRootHifiDataDirectory(), '/Console');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("Root hifi directory is: ", getRootHifiDataDirectory());
|
||||||
console.log("Root directory is: ", getRootHifiDataDirectory());
|
|
||||||
|
|
||||||
const ipcMain = electron.ipcMain;
|
const ipcMain = electron.ipcMain;
|
||||||
|
|
||||||
const osType = os.type();
|
|
||||||
|
|
||||||
var isShuttingDown = false;
|
var isShuttingDown = false;
|
||||||
function shutdown() {
|
function shutdown() {
|
||||||
|
@ -168,7 +174,6 @@ function openFileBrowser(path) {
|
||||||
// Add quotes around path
|
// Add quotes around path
|
||||||
path = '"' + path + '"';
|
path = '"' + path + '"';
|
||||||
if (osType == "Windows_NT") {
|
if (osType == "Windows_NT") {
|
||||||
console.log('start "" ' + path);
|
|
||||||
childProcess.exec('start "" ' + path);
|
childProcess.exec('start "" ' + path);
|
||||||
} else if (osType == "Darwin") {
|
} else if (osType == "Darwin") {
|
||||||
childProcess.exec('open ' + path);
|
childProcess.exec('open ' + path);
|
||||||
|
@ -355,22 +360,27 @@ const httpStatusPort = 60332;
|
||||||
function maybeInstallDefaultContentSet(onComplete) {
|
function maybeInstallDefaultContentSet(onComplete) {
|
||||||
var hasRun = userConfig.get('hasRun', false);
|
var hasRun = userConfig.get('hasRun', false);
|
||||||
|
|
||||||
if (false && hasRun) {
|
if (hasRun) {
|
||||||
|
onComplete();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for existing Stack Manager data
|
// Check for existing AC data
|
||||||
const stackManagerDataPath = getStackManagerDataDirectory();
|
const acResourceDirectory = getAssignmentClientResourcesDirectory();
|
||||||
console.log("Checking for existence of " + stackManagerDataPath);
|
console.log("Checking for existence of " + acResourceDirectory);
|
||||||
var userHasExistingServerData = true;
|
var userHasExistingServerData = true;
|
||||||
try {
|
try {
|
||||||
fs.accessSync(stackManagerDataPath);
|
fs.accessSync(acResourceDirectory);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
userHasExistingServerData = false;
|
userHasExistingServerData = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Existing data?", userHasExistingServerData);
|
if (userHasExistingServerData) {
|
||||||
|
console.log("User has existing data, suppressing downloader");
|
||||||
|
onComplete();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Show popup
|
// Show popup
|
||||||
var window = new BrowserWindow({
|
var window = new BrowserWindow({
|
||||||
|
@ -391,7 +401,7 @@ function maybeInstallDefaultContentSet(onComplete) {
|
||||||
electron.ipcMain.on('ready', function() {
|
electron.ipcMain.on('ready', function() {
|
||||||
console.log("got ready");
|
console.log("got ready");
|
||||||
function sendStateUpdate(state, args) {
|
function sendStateUpdate(state, args) {
|
||||||
console.log(state, window, args);
|
// console.log(state, window, args);
|
||||||
window.webContents.send('update', { state: state, args: args });
|
window.webContents.send('update', { state: state, args: args });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,12 +429,11 @@ function maybeInstallDefaultContentSet(onComplete) {
|
||||||
}), { throttle: 250 }).on('progress', function(state) {
|
}), { throttle: 250 }).on('progress', function(state) {
|
||||||
if (!aborted) {
|
if (!aborted) {
|
||||||
// Update progress popup
|
// Update progress popup
|
||||||
console.log("progress", state);
|
|
||||||
sendStateUpdate('downloading', { progress: state.percentage });
|
sendStateUpdate('downloading', { progress: state.percentage });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var unzipper = unzip.Extract({
|
var unzipper = unzip.Extract({
|
||||||
path: getAssignmentClientResourcesDirectory(),
|
path: acResourceDirectory,
|
||||||
verbose: true
|
verbose: true
|
||||||
});
|
});
|
||||||
unzipper.on('close', function() {
|
unzipper.on('close', function() {
|
||||||
|
@ -454,14 +463,14 @@ function maybeShowSplash() {
|
||||||
var window = new BrowserWindow({
|
var window = new BrowserWindow({
|
||||||
icon: APP_ICON,
|
icon: APP_ICON,
|
||||||
width: 1600,
|
width: 1600,
|
||||||
height: 587,
|
height: 737,
|
||||||
center: true,
|
center: true,
|
||||||
frame: true,
|
frame: true,
|
||||||
useContentSize: true,
|
useContentSize: true,
|
||||||
resizable: false
|
resizable: false
|
||||||
});
|
});
|
||||||
window.loadURL('file://' + __dirname + '/splash.html');
|
window.loadURL('file://' + __dirname + '/splash.html');
|
||||||
window.setMenu(null);
|
// window.setMenu(null);
|
||||||
window.show();
|
window.show();
|
||||||
|
|
||||||
window.webContents.on('new-window', function(e, url) {
|
window.webContents.on('new-window', function(e, url) {
|
||||||
|
|
Loading…
Reference in a new issue